﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Threading.Tasks;
using AutoCAD;

namespace CADAutoPlot
{
    class DrawComponment
    {
        private Dictionary<string, double> windowData;
        private AcadModelSpace modelSpace;
        private Preview previewImg;
        private int type;

        //view:0-vertical,1-front,2:side,pos:1-left 口<,-1-right>口

        //初始化数据
        internal double upperLBoardLength;
        internal double leftLBoardLength;
        internal double rightLBoardLength;

        internal double upperLBoardWidth;
        internal double upperLBoardHeight;
        internal double upperBoardLength;
        internal double lowerBoardLength;

        internal double bladeLength;
        internal double invisPullRod1Length;
        internal double upperBoardWidth;
        internal double lowerBoardWidth;
        internal double bladeWidth;
        internal double invisPullRod1Width;

        internal double upperBoardHeight;
        internal double lowerBoardHeight;
        internal double bladeHeight;
        internal double invisPullRod1Height;

        internal double lboardSlotWidth;
        internal double lboardSlotDept;

        internal double lboardLHeight;

        internal double boardLength;
        internal double boardWidth;
        internal double boardHeight;
        internal double boardSlotWidth;
        internal double boardSlotDept;

        internal double plainEdgeLength;
        internal double hidePlainEdgeLength;
        internal double hideCoverEdgeLength;
        internal double plainCoverEdgeLength;

        internal double plainEdgeWidth;
        internal double hidePlainEdgeWidth;

        internal double plainEdgeHeight;
        internal double hidePlainEdgeHeight;

        //补充
        internal double plainCoverEdgeWidth;
        internal double hideCoverEdgeWidth;

        internal double plainCoverEdgeHeight;
        internal double hideCoverEdgeHeight;

        internal double hidePlainEdgeSlotWidth;

        internal double hidePlainEdgeSlotDept;
        internal double hideCoverEdgeCoverMaxWidth;
        internal double hideCoverEdgeCoverMaxHeight;

        internal double plainCoverEdgeCoverMaxWidth;
        internal double plainCoverEdgeCoverMaxHeight;

        //20250325
        internal double HideCoverEdgerCoverWidth;
        internal double PlainCoverEdgerCoverWidth;
        //20250813
        internal double hingeWidth;
        internal double hingeHeight;
        //20250814
        internal double windowGap;
        internal double lboardLHeight2;
        //20250815
        internal double hingeUpDis1;
        internal double hingeUpDis2;
        internal double hingeUpDis3;
        internal double hingeDownDis1;
        internal double hingeDownDis2;
        internal double hingeDownDis3;
        internal double hingeNum;
        //20250827
        internal double tbarMinWidth;
        internal double tbarMaxWidth;
        internal double tbarHeight;
        internal double tbarCornerHeight;
        internal double tbarLength;
        internal double tbarLeftPos;
        
        //20250828
        internal double windowWidth1;
        internal double windowWidth2;
        //20250902
        internal double tbarRightPos;
        //
        //20250916
        internal int isWindow1Part;
        internal int isWindow2Part;
        internal int isWindow3Part;
        internal int window1UpperArea;
        internal int window2UpperArea;
        internal int window3UpperArea;
        internal int window1LowerArea;
        internal int window2LowerArea;
        internal int window3LowerArea;
        //
        internal int windowNum;
        internal double windowWidth;
        internal int bladeNum;

        public DrawComponment(AcadModelSpace space, int type,Dictionary<string, double> data, Preview previewImg)
        {
            this.modelSpace = space;
            this.windowData = data;
            this.previewImg = previewImg;
            this.type = type;
            //初始化数据
            upperLBoardLength = Common.GetValuesForKey(windowData, "IDC_UPPER_LBOARD_LENGTH");
            leftLBoardLength = Common.GetValuesForKey(windowData, "IDC_LEFT_LBOARD_LENGTH");
            rightLBoardLength = Common.GetValuesForKey(windowData, "IDC_RIGHT_LBOARD_LENGTH");
            upperLBoardWidth = Common.GetValuesForKey(windowData, "IDC_UPPER_LBOARD_WIDTH");
            upperLBoardHeight = Common.GetValuesForKey(windowData, "IDC_UPPER_LBOARD_HEIGHT");
            upperBoardLength = Common.GetValuesForKey(windowData, "IDC_UPPER_BOARD_LENGTH");
            lowerBoardLength = Common.GetValuesForKey(windowData, "IDC_LOWER_BOARD_LENGTH");
            bladeLength = Common.GetValuesForKey(windowData, "IDC_BLADE_LENGTH");
            invisPullRod1Length = Common.GetValuesForKey(windowData, "IDC_INVIS_PULL_ROD1_LENGTH");
            upperBoardWidth = Common.GetValuesForKey(windowData, "IDC_UPPER_BOARD_WIDTH");
            lowerBoardWidth = Common.GetValuesForKey(windowData, "IDC_LOWER_BOARD_WIDTH");
            bladeWidth = Common.GetValuesForKey(windowData, "IDC_BLADE_WIDTH");
            invisPullRod1Width = Common.GetValuesForKey(windowData, "IDC_INVIS_PULL_ROD1_WIDTH");
            upperBoardHeight = Common.GetValuesForKey(windowData, "IDC_UPPER_BOARD_HEIGHT");
            lowerBoardHeight = Common.GetValuesForKey(windowData, "IDC_LOWER_BOARD_HEIGHT");
            bladeHeight = Common.GetValuesForKey(windowData, "IDC_BLADE_HEIGHT");
            invisPullRod1Height = Common.GetValuesForKey(windowData, "IDC_INVIS_PULL_ROD1_HEIGHT");
            lboardSlotWidth = Common.GetValuesForKey(windowData, "IDC_LBOARD_SLOT_WIDTH");
            lboardSlotDept = Common.GetValuesForKey(windowData, "IDC_LBOARD_SLOT_DEPT");
            lboardLHeight = Common.GetValuesForKey(windowData, "IDC_LBOARD_LHEIGHT"); //10
            boardLength = Common.GetValuesForKey(windowData, "IDC_UPPER_BOARD_LENGTH");
            boardWidth = Common.GetValuesForKey(windowData, "IDC_UPPER_BOARD_WIDTH");
            boardHeight = Common.GetValuesForKey(windowData, "IDC_UPPER_BOARD_HEIGHT");
            boardSlotWidth = Common.GetValuesForKey(windowData, "IDC_UPPER_BOARD_SLOT_WIDTH");
            boardSlotDept = Common.GetValuesForKey(windowData, "IDC_UPPER_BOARD_SLOT_DEPT");

            //1
            plainEdgeLength = Common.GetValuesForKey(windowData, "IDC_PLAIN_EDGE_LENGTH");
            hidePlainEdgeLength = Common.GetValuesForKey(windowData, "IDC_HIDE_PLAIN_EDGE_LENGTH");
            hideCoverEdgeLength = Common.GetValuesForKey(windowData, "IDC_HIDE_COVER_EDGE_LENGTH");
            plainCoverEdgeLength = Common.GetValuesForKey(windowData, "IDC_PLAIN_COVER_EDGE_LENGTH");
            plainEdgeWidth = Common.GetValuesForKey(windowData, "IDC_PLAIN_EDGE_WIDTH");
            hidePlainEdgeWidth = Common.GetValuesForKey(windowData, "IDC_HIDE_PLAIN_EDGE_WIDTH");
            plainEdgeHeight = Common.GetValuesForKey(windowData, "IDC_PLAIN_EDGE_HEIGHT");
            hidePlainEdgeHeight = Common.GetValuesForKey(windowData, "IDC_HIDE_PLAIN_EDGE_HEIGHT");
            //补充
            plainCoverEdgeWidth = Common.GetValuesForKey(windowData, "IDC_PLAIN_COVER_EDGE_WIDTH");
            hideCoverEdgeWidth = Common.GetValuesForKey(windowData, "IDC_HIDE_COVER_EDGE_WIDTH");
            plainCoverEdgeHeight = Common.GetValuesForKey(windowData, "IDC_PLAIN_COVER_EDGE_HEIGHT");
            hideCoverEdgeHeight = Common.GetValuesForKey(windowData, "IDC_HIDE_COVER_EDGE_HEIGHT");
            hidePlainEdgeSlotWidth = Common.GetValuesForKey(windowData, "IDC_HIDE_PLAIN_EDGE_SLOT_WIDTH");
            hidePlainEdgeSlotDept = Common.GetValuesForKey(windowData, "IDC_HIDE_PLAIN_EDGE_SLOT_DEPT");
            hideCoverEdgeCoverMaxWidth = Common.GetValuesForKey(windowData, "IDC_HIDE_COVER_EDGE_COVER_MAX_WIDTH");
            hideCoverEdgeCoverMaxHeight = Common.GetValuesForKey(windowData, "IDC_HIDE_COVER_EDGE_COVER_MAX_HEIGHT");
            plainCoverEdgeCoverMaxWidth = Common.GetValuesForKey(windowData, "IDC_PLAIN_COVER_EDGE_COVER_MAX_WIDTH");
            plainCoverEdgeCoverMaxHeight = Common.GetValuesForKey(windowData, "IDC_PLAIN_COVER_EDGE_COVER_MAX_HEIGHT");
            //20250325
            HideCoverEdgerCoverWidth = Common.GetValuesForKey(windowData, "IDC_HIDE_COVER_EDGE_COVER_WIDTH");
            PlainCoverEdgerCoverWidth = Common.GetValuesForKey(windowData, "IDC_PLAIN_COVER_EDGE_COVER_WIDTH");
            //20250813
            hingeWidth = Common.GetValuesForKey(windowData, "IDC_HINGE_WIDTH");
            hingeHeight = Common.GetValuesForKey(windowData, "IDC_HINGE_HEIGHT");
            //20250814
            windowGap = Common.GetValuesForKey(windowData, "IDC_WINDOW_GAP");
            lboardLHeight2 = Common.GetValuesForKey(windowData, "IDC_LBOARD_LHEIGHT2");
            //20250815
            hingeUpDis1 = Common.GetValuesForKey(windowData, "IDC_UP_HINGE_DIS1");
            hingeUpDis2 = Common.GetValuesForKey(windowData, "IDC_UP_HINGE_DIS2");
            hingeUpDis3 = Common.GetValuesForKey(windowData, "IDC_UP_HINGE_DIS3");
            hingeDownDis1 = Common.GetValuesForKey(windowData, "IDC_DOWN_HINGE_DIS1");
            hingeDownDis2 = Common.GetValuesForKey(windowData, "IDC_DOWN_HINGE_DIS2");
            hingeDownDis3 = Common.GetValuesForKey(windowData, "IDC_DOWN_HINGE_DIS3");
            //20250815
            hingeNum = Common.GetValuesForKey(windowData, "IDC_HINGE_NUM");
            //20250827
            tbarMaxWidth = Common.GetValuesForKey(windowData, "IDC_T_BAR_MAX_WIDTH");
            tbarMinWidth = Common.GetValuesForKey(windowData, "IDC_T_BAR_MIN_WIDTH");
            tbarHeight = Common.GetValuesForKey(windowData, "IDC_T_BAR_HEIGHT");
            tbarCornerHeight = Common.GetValuesForKey(windowData, "IDC_T_BAR_CORNER_HEIGHT");
            tbarLength = Common.GetValuesForKey(windowData, "IDC_T_BAR_LENGTH");
            //20250828
            tbarLeftPos = Common.GetValuesForKey(windowData, "IDC_T_BAR_LEFT_POS");
            windowWidth1 = Common.GetValuesForKey(windowData, "IDC_WINDOW_WIDTH1");
            windowWidth2 = Common.GetValuesForKey(windowData, "IDC_WINDOW_WIDTH2");
            //20250902
            tbarRightPos = Common.GetValuesForKey(windowData, "IDC_T_BAR_RIGHT_POS");
            //20250916
            isWindow1Part = Convert.ToInt32(Common.GetValuesForKey(windowData, "IDC_WINDOW1_PART"));
            isWindow2Part = Convert.ToInt32(Common.GetValuesForKey(windowData, "IDC_WINDOW2_PART"));
            isWindow3Part = Convert.ToInt32(Common.GetValuesForKey(windowData, "IDC_WINDOW3_PART"));
            window1UpperArea = Convert.ToInt32(Common.GetValuesForKey(windowData, "IDC_WINDOW1_UPPER_AREA"));
            window2UpperArea = Convert.ToInt32(Common.GetValuesForKey(windowData, "IDC_WINDOW2_UPPER_AREA"));
            window3UpperArea = Convert.ToInt32(Common.GetValuesForKey(windowData, "IDC_WINDOW3_UPPER_AREA"));
            window1LowerArea = Convert.ToInt32(Common.GetValuesForKey(windowData, "IDC_WINDOW1_LOWER_AREA"));
            window2LowerArea = Convert.ToInt32(Common.GetValuesForKey(windowData, "IDC_WINDOW2_LOWER_AREA"));
            window3LowerArea = Convert.ToInt32(Common.GetValuesForKey(windowData, "IDC_WINDOW3_LOWER_AREA"));
            //
            windowNum = (int)Common.GetValuesForKey(windowData, "IDC_WINDOW_NUM");
            windowWidth = Common.GetValuesForKey(windowData, "IDC_WINDOW_WIDTH");
            bladeNum = (int)Common.GetValuesForKey(windowData, "IDC_BLADE_NUM");

        }

        //画L槽框
        public void DrawLBoard(Point startPoint, int view)
        {
            int pos = 1;
            double[] LBoardStartPoints,LBoardEndPoints;
            double[] LBoardStartPoints1,LBoardEndPoints1;
            double[] LBoardStartPoints2,LBoardEndPoints2;
            double[] LBoardStartPoints3,LBoardEndPoints3;
            double[] TBoardPoints,TBoardPoints1,TBoardStartPoint, TBoardStartPoint1;
            double[] textPos,textPos1,textPos2;

            AcadPolyline UpBoard,DownBoard,LeftBoard,RightBoard,TBoard, TBoard1;

            switch (view)
            {
                case 0:
                    //画轮廓线
                    //画左
                    LBoardStartPoints = DrawDoubleLSlot(startPoint,0,1);
                    LeftBoard = modelSpace.AddPolyline(LBoardStartPoints);
                    LeftBoard.Closed = true;
                    previewImg.AddPolyLine(LBoardStartPoints);

                    //画窗线1
                    LBoardStartPoints1 = new double[]{ startPoint.getX(), startPoint.getY(),startPoint.getZ() };
                    LBoardEndPoints1 = new double[] { startPoint.getX() + upperLBoardLength, startPoint.getY(),startPoint.getZ() };
                    modelSpace.AddLine(LBoardStartPoints1, LBoardEndPoints1);
                    previewImg.AddLine(LBoardStartPoints1, LBoardEndPoints1);
                    //画窗线2
                    if(type != 3 && type != 4)
                    {
                        LBoardStartPoints2 = new double[] { startPoint.getX() + upperLBoardWidth, startPoint.getY() - lboardLHeight, startPoint.getZ() };
                        LBoardEndPoints2 = new double[] { startPoint.getX() + (upperLBoardLength - upperLBoardWidth), startPoint.getY() - lboardLHeight, startPoint.getZ() };
                        modelSpace.AddLine(LBoardStartPoints2, LBoardEndPoints2);
                        previewImg.AddLine(LBoardStartPoints2, LBoardEndPoints2);
                    }
                    else
                    {
                        if(type == 3)
                        {
                            LBoardStartPoints2 = new double[] { startPoint.getX() + upperLBoardWidth, startPoint.getY() - lboardLHeight, startPoint.getZ() };
                            LBoardEndPoints2 = new double[] { startPoint.getX() + tbarLeftPos - ((tbarMinWidth) / 2), startPoint.getY() - lboardLHeight, startPoint.getZ() };
                            modelSpace.AddLine(LBoardStartPoints2, LBoardEndPoints2);
                            previewImg.AddLine(LBoardStartPoints2, LBoardEndPoints2);

                            LBoardStartPoints2 = new double[] { startPoint.getX() + tbarLeftPos + ((tbarMinWidth) / 2), startPoint.getY() - lboardLHeight, startPoint.getZ() };
                            LBoardEndPoints2 = new double[] { startPoint.getX() + (upperLBoardLength - upperLBoardWidth), startPoint.getY() - lboardLHeight, startPoint.getZ() };
                            modelSpace.AddLine(LBoardStartPoints2, LBoardEndPoints2);
                            previewImg.AddLine(LBoardStartPoints2, LBoardEndPoints2);
                        }
                        else
                        {
                            
                            //左柱
                            LBoardStartPoints2 = new double[] { startPoint.getX() + upperLBoardWidth, startPoint.getY() - lboardLHeight, startPoint.getZ() };
                            LBoardEndPoints2 = new double[] { startPoint.getX() + tbarLeftPos - ((tbarMinWidth) / 2), startPoint.getY() - lboardLHeight, startPoint.getZ() };
                            modelSpace.AddLine(LBoardStartPoints2, LBoardEndPoints2);
                            previewImg.AddLine(LBoardStartPoints2, LBoardEndPoints2);

                            //右柱
                            LBoardStartPoints2 = new double[] { startPoint.getX() + tbarLeftPos + ((tbarMinWidth) / 2), startPoint.getY() - lboardLHeight, startPoint.getZ() };
                            LBoardEndPoints2 = new double[] { startPoint.getX() + tbarRightPos - ((tbarMinWidth) / 2), startPoint.getY() - lboardLHeight, startPoint.getZ() };
                            modelSpace.AddLine(LBoardStartPoints2, LBoardEndPoints2);
                            previewImg.AddLine(LBoardStartPoints2, LBoardEndPoints2);

                            LBoardStartPoints2 = new double[] { startPoint.getX() + tbarRightPos + ((tbarMinWidth) / 2), startPoint.getY() - lboardLHeight, startPoint.getZ() };
                            LBoardEndPoints2 = new double[] { startPoint.getX() + (upperLBoardLength - upperLBoardWidth), startPoint.getY() - lboardLHeight, startPoint.getZ() };
                            modelSpace.AddLine(LBoardStartPoints2, LBoardEndPoints2);
                            previewImg.AddLine(LBoardStartPoints2, LBoardEndPoints2);
                        }
                    }
                    //画右
                    LBoardStartPoints3 = DrawDoubleLSlot(new Point(startPoint.getX() + upperLBoardLength, startPoint.getY(), startPoint.getZ()), 0, -1);
                    RightBoard = modelSpace.AddPolyline(LBoardStartPoints3);
                    RightBoard.Closed = true;
                    previewImg.AddPolyLine(LBoardStartPoints3);
                    //尺寸标注
                    textPos = new double[] {(LBoardEndPoints1[0] + LBoardEndPoints1[0]) / 2, LBoardEndPoints1[1] + 45, 0 };
                    AcadDimAligned aligned = modelSpace.AddDimAligned(LBoardStartPoints1, LBoardEndPoints1, textPos);
                    aligned.TextHeight = 10;
                    aligned.Update();

                    if (type == 3)
                    {
                            TBoardStartPoint = new double[] { startPoint.getX() + tbarLeftPos , startPoint.getY(), startPoint.getZ() };
                            TBoardPoints = DrawTBar(new Point(TBoardStartPoint[0] - (tbarMaxWidth / 2), TBoardStartPoint[1], TBoardStartPoint[2]), 0);
                            
                            TBoard = modelSpace.AddPolyline(TBoardPoints);
                            TBoard.Closed = true;
                            previewImg.AddPolyLine(TBoardPoints);
                            //尺寸标注
                            textPos1 = new double[] { (LBoardEndPoints1[0] + TBoardStartPoint[0]) / 2, LBoardEndPoints1[1] + 15, 0 };
                            AcadDimAligned aligned2 = modelSpace.AddDimAligned(LBoardStartPoints1, TBoardStartPoint, textPos);
                            aligned2.TextHeight = 10;
                            aligned2.Update();

                     }
                     else if (type == 4)
                     {
                            //左T柱
                            TBoardStartPoint = new double[] { startPoint.getX() + tbarLeftPos, startPoint.getY(), startPoint.getZ() };
                            TBoardPoints = DrawTBar(new Point(TBoardStartPoint[0] - (tbarMaxWidth / 2), TBoardStartPoint[1], TBoardStartPoint[2]), 0);
                            TBoard = modelSpace.AddPolyline(TBoardPoints);
                            TBoard.Closed = true;
                            previewImg.AddPolyLine(TBoardPoints);

                            //右T柱
                            TBoardStartPoint1 = new double[] { startPoint.getX() + tbarRightPos, startPoint.getY(), startPoint.getZ() };
                            TBoardPoints1 = DrawTBar(new Point(TBoardStartPoint1[0] - (tbarMaxWidth / 2), TBoardStartPoint[1], TBoardStartPoint[2]), 0);
                            TBoard1 = modelSpace.AddPolyline(TBoardPoints1);
                            TBoard1.Closed = true;
                            previewImg.AddPolyLine(TBoardPoints1);

                            //尺寸标注
                            textPos1 = new double[] { (LBoardStartPoints1[0] + TBoardStartPoint[0]) / 2, LBoardStartPoints1[1] + 10, 0 };
                            AcadDimAligned aligned2 = modelSpace.AddDimAligned(LBoardStartPoints1, TBoardStartPoint, textPos1);
                            aligned2.TextHeight = 10;
                            aligned2.Update();

                            //尺寸标注
                            textPos2 = new double[] { (LBoardStartPoints1[0] + TBoardStartPoint1[0]) / 2, LBoardStartPoints1[1] + 25, 0 };
                            AcadDimAligned aligned4 = modelSpace.AddDimAligned(LBoardStartPoints1, TBoardStartPoint1, textPos2);
                            aligned4.TextHeight = 10;
                            aligned4.Update();
                    }

                    break;
                case 1:
                    //画上框
                    LBoardStartPoints = new double[]{
                          startPoint.getX(),startPoint.getY(),startPoint.getZ(),//1
                          startPoint.getX() + upperLBoardLength,startPoint.getY(),startPoint.getZ(),//2
                          startPoint.getX() + upperLBoardLength - lboardLHeight2,startPoint.getY() - lboardLHeight2,startPoint.getZ(),//3
                          startPoint.getX() + lboardLHeight2,startPoint.getY() - lboardLHeight2,startPoint.getZ() //4
                    };
                    UpBoard = modelSpace.AddPolyline(LBoardStartPoints);
                    UpBoard.Closed = true;
                    previewImg.AddPolyLine(LBoardStartPoints);
                    //画左框
                    LBoardStartPoints1 = new double[]{
                         startPoint.getX(),startPoint.getY(),startPoint.getZ(),//1
                         startPoint.getX(),startPoint.getY() - leftLBoardLength,startPoint.getZ(),//2
                         startPoint.getX() + lboardLHeight2,windowNum <= 1 ? startPoint.getY() - leftLBoardLength:startPoint.getY() - (leftLBoardLength - lboardLHeight2),startPoint.getZ(),//3
                         startPoint.getX() + lboardLHeight2,startPoint.getY() - lboardLHeight2,startPoint.getZ() //4
                    };
                    LeftBoard = modelSpace.AddPolyline(LBoardStartPoints1);
                    LeftBoard.Closed = true;
                    previewImg.AddPolyLine(LBoardStartPoints1);
                    //画右框
                    LBoardStartPoints2 = new double[]
                    {
                         startPoint.getX() + upperLBoardLength,startPoint.getY(),startPoint.getZ(),//1
                         startPoint.getX() + upperLBoardLength,startPoint.getY() - rightLBoardLength,startPoint.getZ(),//2
                         startPoint.getX() + upperLBoardLength - lboardLHeight2,windowNum <=1 ? startPoint.getY() - rightLBoardLength :  startPoint.getY() - (rightLBoardLength - lboardLHeight2),startPoint.getZ(),//3
                         startPoint.getX() + upperLBoardLength - lboardLHeight2,startPoint.getY() - lboardLHeight2,startPoint.getZ() //4
                    };
                    RightBoard = modelSpace.AddPolyline(LBoardStartPoints2);
                    RightBoard.Closed = true;
                    previewImg.AddPolyLine(LBoardStartPoints2);
                    //窗户数量大于1时，有下框
                    if (windowNum > 1)
                    {
                        LBoardStartPoints3 = new double[]
                        {
                            startPoint.getX() + lboardLHeight2,startPoint.getY() - (leftLBoardLength - lboardLHeight2),startPoint.getZ(),//1
                            startPoint.getX() + upperLBoardLength - lboardLHeight2,startPoint.getY() - (rightLBoardLength - lboardLHeight2),startPoint.getZ(),//2
                            startPoint.getX() + upperLBoardLength,startPoint.getY() - rightLBoardLength,startPoint.getZ(),//3
                            startPoint.getX(),startPoint.getY() - leftLBoardLength,startPoint.getZ() //4
                        };
                        DownBoard = modelSpace.AddPolyline(LBoardStartPoints3);
                        DownBoard.Closed = true;
                        previewImg.AddPolyLine(LBoardStartPoints3);
                        if (windowNum >= 3)
                        {
                            if (type == 3)
                            {
                                TBoardPoints = DrawTBar(new Point(startPoint.getX() + tbarLeftPos - (tbarMinWidth / 2),startPoint.getY() - lboardLHeight2,startPoint.getZ()), 1);
                                TBoard = modelSpace.AddPolyline(TBoardPoints);
                                TBoard.Closed = true;
                                previewImg.AddPolyLine(TBoardPoints);
                            }
                            else if (type == 4)
                            {
                                TBoardPoints = DrawTBar(new Point(startPoint.getX() + tbarLeftPos - (tbarMinWidth / 2), startPoint.getY() - lboardLHeight2, startPoint.getZ()), 1);
                                TBoard = modelSpace.AddPolyline(TBoardPoints);
                                TBoard.Closed = true;
                                previewImg.AddPolyLine(TBoardPoints);

                                TBoardPoints1 = DrawTBar(new Point(startPoint.getX() + tbarRightPos - (tbarMinWidth / 2), startPoint.getY() - lboardLHeight2, startPoint.getZ()), 1);
                                TBoard1 = modelSpace.AddPolyline(TBoardPoints1);
                                TBoard1.Closed = true;
                                previewImg.AddPolyLine(TBoardPoints1);
                            }
                        }
                    }

                    //尺寸标注
                    textPos = new double[] { (startPoint.getX() + startPoint.getX() + upperLBoardLength) / 2, startPoint.getY() + 25, 0 };
                    AcadDimAligned aligned1 = modelSpace.AddDimAligned(new double[] { startPoint.getX(), startPoint.getY(), startPoint.getZ() }, new double[] { startPoint.getX() + upperLBoardLength, startPoint.getY(), startPoint.getZ() }, textPos);
                    aligned1.TextHeight = 10;
                    aligned1.Update();
                    break;
                case 2:
                    if (windowNum <= 1)
                    {
                        pos = 1;
                        LBoardStartPoints = DrawDoubleLSlot(startPoint, 2, 1);
                        UpBoard = modelSpace.AddPolyline(LBoardStartPoints);
                        UpBoard.Closed = true;
                        previewImg.AddPolyLine(LBoardStartPoints);
                        //画线1
                        LBoardStartPoints = new double[] {startPoint.getX(),startPoint.getY(),startPoint.getZ()};
                        LBoardEndPoints = new double[] { startPoint.getX() ,startPoint.getY() - leftLBoardLength, startPoint.getY() };
                        modelSpace.AddLine(LBoardStartPoints,LBoardEndPoints);
                        previewImg.AddLine(LBoardStartPoints,LBoardEndPoints);
                        //画线2
                        LBoardStartPoints1 = new double[] { startPoint.getX() + lboardLHeight , startPoint.getY() - upperLBoardWidth, startPoint.getY() };
                        LBoardEndPoints1 = new double[] { startPoint.getX() + lboardLHeight , startPoint.getY() - leftLBoardLength, startPoint.getY() };
                        modelSpace.AddLine(LBoardStartPoints1, LBoardEndPoints1);
                        previewImg.AddLine(LBoardStartPoints1,LBoardEndPoints1);
                        //画线3
                        LBoardStartPoints2 = new double[] { startPoint.getX() ,startPoint.getY() - leftLBoardLength, startPoint.getZ() };
                        LBoardEndPoints2 = new double[] { startPoint.getX() + lboardLHeight , startPoint.getY() - leftLBoardLength, startPoint.getZ() };
                        modelSpace.AddLine(LBoardStartPoints2, LBoardEndPoints2);
                        previewImg.AddLine(LBoardStartPoints2,LBoardEndPoints2);
                    }
                    else
                    {
                        pos = 1;
                        LBoardStartPoints = DrawDoubleLSlot(startPoint, 2, pos);
                        UpBoard = modelSpace.AddPolyline(LBoardStartPoints);
                        UpBoard.Closed = true;
                        previewImg.AddPolyLine(LBoardStartPoints);
                        //
                        pos = -1 * pos;
                        startPoint = new Point(startPoint.getX(), startPoint.getY() - leftLBoardLength,startPoint.getZ());
                        LBoardStartPoints1 = DrawDoubleLSlot(startPoint, 2, pos);
                        DownBoard = modelSpace.AddPolyline(LBoardStartPoints1);
                        DownBoard.Closed = true;
                        previewImg.AddPolyLine(LBoardStartPoints1);
                        //
                        //画线1
                        LBoardStartPoints2 = new double[] { startPoint.getX(),startPoint.getY(),startPoint.getZ()};
                        LBoardEndPoints2 = new double[] { startPoint.getX(), startPoint.getY() + leftLBoardLength, startPoint.getZ() };
                        modelSpace.AddLine(LBoardStartPoints2 , LBoardEndPoints2);
                        previewImg.AddLine(LBoardStartPoints2,LBoardEndPoints2);
                        //画线2
                        LBoardStartPoints3 = new double[] { startPoint.getX() + lboardLHeight ,startPoint.getY() + lboardLHeight2, startPoint.getZ() };
                        LBoardEndPoints3 = new double[] { startPoint.getX() + lboardLHeight ,startPoint.getY() + lboardLHeight2 + hidePlainEdgeLength, startPoint.getZ() };
                        modelSpace.AddLine(LBoardStartPoints3, LBoardEndPoints3);
                        previewImg.AddLine(LBoardStartPoints3,LBoardEndPoints3);
                    }

                    //尺寸标注
                    textPos = new double[] { startPoint.getX() - 35, (startPoint.getY() + startPoint.getY() - pos * leftLBoardLength) / 2, 0 };
                    AcadDimRotated aligned3 = modelSpace.AddDimRotated(new double[] { startPoint.getX(), startPoint.getY(), startPoint.getZ() }, new double[] { startPoint.getX(), startPoint.getY() - pos * leftLBoardLength, startPoint.getY() }, textPos, Math.PI / 2);
                    aligned3.TextHeight = 10;
                    aligned3.Update();
                    break;
            }
        }
        
        //画门边框
        public void DrawEdge(Point startPoint, int view)
        {
            int pos = 1;
            double[] edgeStartPoints, edgeEndPoints, edgeStartPoints1, edgeEndPoints1, edgeStartPoints2, edgeEndPoints2, edgeStartPoints3, edgeEndPoints3, edgeStartPoints4, edgeEndPoints4, edgeStartPoints5, edgeEndPoints5, edgeStartPoints6, edgeEndPoints6, edgeStartPoints7, edgeEndPoints7, edgeStartPoints8, textPos;
            AcadPolyline edge,edge1,edge2,edge3,edge4,edge5;
            switch (view)
            {
                case 0:
                    if (windowNum == 1)
                    {
                        //单窗户以右上角为基准点，其他相反
                        //绘制隐形平门边
                        pos = -1;
                        //startPoint = new Point(startPoint.getX(), startPoint.getY(), startPoint.getZ());
                        edgeStartPoints = DrawSingleEdge(startPoint, 0, pos, 0);
                        edge = modelSpace.AddPolyline(edgeStartPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        // 绘制平门边
                        edgeEndPoints = DrawSingleEdge(new Point(startPoint.getX() - hidePlainEdgeWidth - windowWidth, startPoint.getY(), startPoint.getZ()), 0, pos, 1);
                        edge1 = modelSpace.AddPolyline(edgeEndPoints);
                        edge1.Closed = true;
                        previewImg.AddPolyLine(edgeEndPoints);
                        //画线上(窗户)
                        edgeStartPoints1 = new double[] { startPoint.getX() + (double)pos * hidePlainEdgeWidth, startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                        edgeEndPoints1 = new double[] { startPoint.getX() + (double)pos * (hidePlainEdgeWidth + windowWidth), startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ()};
                        modelSpace.AddLine(edgeStartPoints1, edgeEndPoints1);
                        previewImg.AddLine(edgeStartPoints1,edgeEndPoints1);
                        //画线下(窗户)
                        edgeStartPoints2 = new double[] { startPoint.getX() + (double)pos * hidePlainEdgeWidth, startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0,startPoint.getZ() };
                        edgeEndPoints2 = new double[] { startPoint.getX() + (double)pos * (hidePlainEdgeWidth + windowWidth), startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0,startPoint.getZ() };
                        modelSpace.AddLine(edgeStartPoints2, edgeEndPoints2);
                        previewImg.AddLine(edgeStartPoints2,edgeEndPoints2);
                        //窗户尺寸标注
                        textPos = new double[] { (edgeEndPoints[9] + edgeStartPoints[18]) / 2, edgeStartPoints[19] - 15, 0 };
                        AcadDimAligned aligned1 = modelSpace.AddDimAligned(new double[] {edgeEndPoints[9], edgeEndPoints[10], edgeEndPoints[11] }, new double[] { edgeStartPoints[18], edgeStartPoints[19], edgeStartPoints[20] }, textPos);
                        aligned1.TextHeight = 10;
                        aligned1.Update();
                        //窗框尺寸标注
                        textPos = new double[] { (edgeEndPoints[6] + edgeStartPoints[21]) / 2, edgeStartPoints[22] - 35, 0 };
                        AcadDimAligned aligned2 = modelSpace.AddDimAligned(new double[] { edgeEndPoints[6], edgeEndPoints[7], edgeEndPoints[8] }, new double[] { edgeStartPoints[21], edgeStartPoints[22], edgeStartPoints[23] }, textPos);
                        aligned2.TextHeight = 10;
                        aligned2.Update();
                    }
                    else if (windowNum == 2)
                    {

                        //隐藏平门边
                        edgeStartPoints = DrawSingleEdge(startPoint, 0, 1, 0);
                        edge = modelSpace.AddPolyline(edgeStartPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        //画线(窗户)
                        edgeStartPoints1 = new double[] { startPoint.getX() + hidePlainEdgeWidth,startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ()};
                        edgeEndPoints1 = new double[] { startPoint.getX() + hidePlainEdgeWidth + windowWidth, startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                        modelSpace.AddLine(edgeStartPoints1, edgeEndPoints1);
                        previewImg.AddLine(edgeStartPoints1,edgeEndPoints1);

                        edgeStartPoints1 = new double[] { startPoint.getX() + hidePlainEdgeWidth,startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                        edgeEndPoints1 = new double[] { startPoint.getX() + hidePlainEdgeWidth + windowWidth, startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                        modelSpace.AddLine(edgeStartPoints1, edgeEndPoints1);
                        previewImg.AddLine(edgeStartPoints1,edgeEndPoints1);
                        //调整起始点
                        startPoint = new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth, startPoint.getY(), startPoint.getZ());
                        //平盖片门边
                        edgeStartPoints2 = DrawSingleEdge(startPoint, 0, 1, 3);
                        edge1 = modelSpace.AddPolyline(edgeStartPoints2);
                        edge1.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints2);
                        //平门边
                        //edgeStartPoints = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + bladeLength + plainEdgeWidth, startPoint.getY(), startPoint.getZ()), 0, pos, 1);
                        edgeStartPoints3 = DrawSingleEdge(new Point(startPoint.getX()  + plainCoverEdgeWidth + windowGap, startPoint.getY(), startPoint.getZ()), 0, pos, 1);
                        edge2 = modelSpace.AddPolyline(edgeStartPoints3);
                        edge2.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints3);
                        //隐藏平门边
                        startPoint = new Point(startPoint.getX() + plainCoverEdgeWidth + windowGap + plainEdgeWidth + windowWidth1 + hidePlainEdgeWidth, startPoint.getY(),startPoint.getZ());
                        edgeStartPoints4 = DrawSingleEdge(startPoint, 0, -1, 0);
                        edge3 = modelSpace.AddPolyline(edgeStartPoints4);
                        edge3.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints4);
                        //画线(窗户)
                        edgeStartPoints5 = new double[] { startPoint.getX() - hidePlainEdgeWidth,startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0,startPoint.getZ()};
                        edgeEndPoints5 = new double[] { startPoint.getX() - hidePlainEdgeWidth - windowWidth1, startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ()};
                        modelSpace.AddLine(edgeStartPoints5, edgeEndPoints5);
                        previewImg.AddLine(edgeStartPoints5,edgeEndPoints5);

                        edgeStartPoints5 = new double[] { startPoint.getX() - hidePlainEdgeWidth,startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                        edgeEndPoints5 = new double[] { startPoint.getX() - hidePlainEdgeWidth - windowWidth1, startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                        modelSpace.AddLine(edgeStartPoints5, edgeEndPoints5);
                        previewImg.AddLine(edgeStartPoints5,edgeEndPoints5);

                        //窗户尺寸标注
                        textPos = new double[] { (edgeStartPoints1[0] + edgeEndPoints1[0]) / 2, edgeStartPoints1[1] - 15, 0 };
                        AcadDimAligned aligned1 = modelSpace.AddDimAligned(new double[] { edgeStartPoints1[0], edgeStartPoints1[1] - 10, edgeStartPoints1[2] }, new double[] { edgeEndPoints1[0], edgeEndPoints1[1] - 10, edgeEndPoints1[2] }, textPos);
                        aligned1.TextHeight = 10;
                        aligned1.Update();

                        textPos = new double[] { (edgeStartPoints5[0] + edgeEndPoints5[0]) / 2, edgeStartPoints5[1] - 15, 0 };
                        AcadDimAligned aligned2 = modelSpace.AddDimAligned(new double[] { edgeStartPoints5[0], edgeStartPoints5[1] - 10, edgeStartPoints5[2] }, new double[] { edgeEndPoints5[0], edgeEndPoints5[1] - 10, edgeEndPoints5[2] }, textPos);
                        aligned2.TextHeight = 10;
                        aligned2.Update();

                        //窗框尺寸标注
                        textPos = new double[] { (edgeStartPoints[21] + edgeStartPoints2[3]) / 2, edgeStartPoints[22] - 35, 0 };
                        AcadDimAligned aligned3 = modelSpace.AddDimAligned(new double[] { edgeStartPoints[21], edgeStartPoints[22] - 10, edgeStartPoints[23] }, new double[] { edgeStartPoints2[3], edgeStartPoints2[22] - 10, edgeStartPoints2[23] }, textPos);
                        aligned3.TextHeight = 10;
                        aligned3.Update();

                        textPos = new double[] { (edgeStartPoints3[9] + edgeStartPoints4[21]) / 2, edgeStartPoints3[10] - 35, 0 };
                        AcadDimAligned aligned4 = modelSpace.AddDimAligned(new double[] { edgeStartPoints3[9], edgeStartPoints3[10] - 10, edgeStartPoints3[11] }, new double[] { edgeStartPoints4[21], edgeStartPoints4[22] - 10, edgeStartPoints4[23] }, textPos);
                        aligned4.TextHeight = 10;
                        aligned4.Update();
                    }
                    else if (windowNum == 3)
                    {
                        //隐藏平门边
                        edgeStartPoints = DrawSingleEdge(startPoint, 0, 1, 0);
                        edge = modelSpace.AddPolyline(edgeStartPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        //画线(窗户)
                        edgeStartPoints1 = new double[] { startPoint.getX() + hidePlainEdgeWidth,startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                        edgeEndPoints1 = new double[]  { startPoint.getX() + hidePlainEdgeWidth + windowWidth, startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0,startPoint.getZ() };
                        modelSpace.AddLine(edgeStartPoints1, edgeEndPoints1);
                        previewImg.AddLine(edgeStartPoints1,edgeEndPoints1);

                        edgeStartPoints1 = new double[] { startPoint.getX() + hidePlainEdgeWidth,startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                        edgeEndPoints1 = new double[] { startPoint.getX() + hidePlainEdgeWidth + windowWidth, startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                        modelSpace.AddLine(edgeStartPoints1, edgeEndPoints1);
                        previewImg.AddLine(edgeStartPoints1,edgeEndPoints1);

                        //平门边
                        edgeStartPoints2 = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth, startPoint.getY(), startPoint.getZ()), 0, pos, 1);
                        edge1 = modelSpace.AddPolyline(edgeStartPoints2);
                        edge1.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints2);
                        if (type == 3 || type == 4)
                        {
                            
                            pos = -1 * pos;
                            if (type == 3)
                            {
                                //调整起始点
                                startPoint = new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap + plainCoverEdgeWidth, startPoint.getY(), startPoint.getZ());

                                //平盖片门边
                                edgeStartPoints3 = DrawSingleEdge(startPoint, 0, pos, 3);
                                edge2 = modelSpace.AddPolyline(edgeStartPoints3);
                                edge2.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints3);

                                //画线(窗户)
                                edgeStartPoints4 = new double[] { startPoint.getX(), startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                                edgeEndPoints4 = new double[] { startPoint.getX() + windowWidth1, startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                                modelSpace.AddLine(edgeStartPoints4, edgeEndPoints4);
                                previewImg.AddLine(edgeStartPoints4, edgeEndPoints4);

                                edgeStartPoints4 = new double[] { startPoint.getX(), startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                                edgeEndPoints4 = new double[] { startPoint.getX() + windowWidth1, startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                                modelSpace.AddLine(edgeStartPoints4, edgeEndPoints4);
                                previewImg.AddLine(edgeStartPoints4, edgeEndPoints4);
                                //隐形平门边
                                startPoint = new Point(edgeEndPoints4[0] + hidePlainEdgeWidth, startPoint.getY(), startPoint.getZ());
                                edgeStartPoints5 = DrawSingleEdge(startPoint, 0, pos, 0);
                                edge3 = modelSpace.AddPolyline(edgeStartPoints5);
                                edge3.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints5);

                                //平门边
                                
                                startPoint = new Point(startPoint.getX() + plainEdgeWidth + windowGap + tbarMinWidth + windowGap, startPoint.getY(), startPoint.getZ());
                                edgeStartPoints6 = DrawSingleEdge(startPoint, 0, pos, 1);
                                edge4 = modelSpace.AddPolyline(edgeStartPoints6);
                                edge4.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints6);
                                //画窗框线
                                edgeStartPoints7 = new double[] { startPoint.getX(), startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                                edgeEndPoints7 = new double[] { startPoint.getX() + windowWidth2, startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                                modelSpace.AddLine(edgeStartPoints7, edgeEndPoints7);
                                previewImg.AddLine(edgeStartPoints7, edgeEndPoints7);

                                edgeStartPoints7 = new double[] { startPoint.getX(), startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                                edgeEndPoints7 = new double[] { startPoint.getX() + windowWidth2, startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                                modelSpace.AddLine(edgeStartPoints7, edgeEndPoints7);
                                previewImg.AddLine(edgeStartPoints7, edgeEndPoints7);

                                //隐藏平门边
                                startPoint = new Point(startPoint.getX() + windowWidth2 + hidePlainEdgeWidth, startPoint.getY(), startPoint.getZ());
                                edgeStartPoints8 = DrawSingleEdge(startPoint, 0, pos, 0);
                                edge5 = modelSpace.AddPolyline(edgeStartPoints8);
                                edge5.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints8);

                                //窗框尺寸标注
                                textPos = new double[] { (edgeStartPoints[21] + edgeStartPoints2[6]) / 2, edgeStartPoints[22] - 35, 0 };
                                AcadDimAligned aligned4 = modelSpace.AddDimAligned(new double[] { edgeStartPoints[21], edgeStartPoints[22] - 15, edgeStartPoints[23] }, new double[] { edgeStartPoints2[6], edgeStartPoints2[7] - 15, edgeStartPoints2[8] }, textPos);
                                aligned4.TextHeight = 10;
                                aligned4.Update();

                                textPos = new double[] { (edgeStartPoints3[6] + edgeStartPoints5[21]) / 2, edgeStartPoints3[7] - 35, 0 };
                                AcadDimAligned aligned5 = modelSpace.AddDimAligned(new double[] { edgeStartPoints3[6], edgeStartPoints3[7] - 15, edgeStartPoints3[8] }, new double[] { edgeStartPoints5[21], edgeStartPoints5[22] - 15, edgeStartPoints5[23] }, textPos);
                                aligned5.TextHeight = 10;
                                aligned5.Update();

                                textPos = new double[] { (edgeStartPoints6[3] + edgeStartPoints8[21]) / 2, edgeStartPoints6[7] - 35, 0 };
                                AcadDimAligned aligned6 = modelSpace.AddDimAligned(new double[] { edgeStartPoints6[3], edgeStartPoints6[7] - 15, edgeStartPoints6[2] }, new double[] { edgeStartPoints8[21], edgeStartPoints8[22] - 15, edgeStartPoints8[23] }, textPos);
                                aligned6.TextHeight = 10;
                                aligned6.Update();
                            }
                            else
                            {
                                //调整起始点
                                startPoint = new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap + tbarMinWidth + windowGap, startPoint.getY(), startPoint.getZ());

                                //平门边
                                edgeStartPoints3 = DrawSingleEdge(startPoint, 0, 1, 1);
                                edge2 = modelSpace.AddPolyline(edgeStartPoints3);
                                edge2.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints3);

                                //画线(窗户)
                                edgeStartPoints4 = new double[] { startPoint.getX() + plainEdgeWidth, startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                                edgeEndPoints4 = new double[] { startPoint.getX() + plainEdgeWidth + windowWidth1, startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                                modelSpace.AddLine(edgeStartPoints4, edgeEndPoints4);
                                previewImg.AddLine(edgeStartPoints4, edgeEndPoints4);

                                edgeStartPoints4 = new double[] { startPoint.getX() + plainEdgeWidth, startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                                edgeEndPoints4 = new double[] { startPoint.getX() + plainEdgeWidth + windowWidth1, startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                                modelSpace.AddLine(edgeStartPoints4, edgeEndPoints4);
                                previewImg.AddLine(edgeStartPoints4, edgeEndPoints4);
                                //隐形平门边
                                startPoint = new Point(edgeEndPoints4[0] + hidePlainEdgeWidth, startPoint.getY(), startPoint.getZ());
                                edgeStartPoints5 = DrawSingleEdge(startPoint, 0, pos, 0);
                                edge3 = modelSpace.AddPolyline(edgeStartPoints5);
                                edge3.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints5);

                                //平门边
                                startPoint = new Point(startPoint.getX() + windowGap + tbarMinWidth + windowGap + plainEdgeWidth, startPoint.getY(), startPoint.getZ());
                                edgeStartPoints6 = DrawSingleEdge(startPoint, 0, pos, 1);
                                edge4 = modelSpace.AddPolyline(edgeStartPoints6);
                                edge4.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints6);


                                //画窗框线
                                edgeStartPoints7 = new double[] { startPoint.getX(), startPoint.getY() - ((hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0), startPoint.getZ() };
                                edgeEndPoints7 = new double[] { startPoint.getX() + windowWidth2, startPoint.getY() - ((hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0), startPoint.getZ() };
                                modelSpace.AddLine(edgeStartPoints7, edgeEndPoints7);
                                previewImg.AddLine(edgeStartPoints7, edgeEndPoints7);

                                edgeStartPoints7 = new double[] { startPoint.getX(), startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                                edgeEndPoints7 = new double[] { startPoint.getX() + windowWidth2, startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                                modelSpace.AddLine(edgeStartPoints7, edgeEndPoints7);
                                previewImg.AddLine(edgeStartPoints7, edgeEndPoints7);

                                //隐藏平门边
                                startPoint = new Point(startPoint.getX() + windowWidth2 + hidePlainEdgeWidth, startPoint.getY(), startPoint.getZ());
                                edgeStartPoints8 = DrawSingleEdge(startPoint, 0, pos, 0);
                                edge5 = modelSpace.AddPolyline(edgeStartPoints8);
                                edge5.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints8);

                                //窗框尺寸标注
                                textPos = new double[] { (edgeStartPoints[21] + edgeStartPoints2[6]) / 2, edgeStartPoints[22] - 35, 0 };
                                AcadDimAligned aligned4 = modelSpace.AddDimAligned(new double[] { edgeStartPoints[21], edgeStartPoints[22] - 15, edgeStartPoints[23] }, new double[] { edgeStartPoints2[6], edgeStartPoints2[7] - 15, edgeStartPoints2[8] }, textPos);
                                aligned4.TextHeight = 10;
                                aligned4.Update();

                                textPos = new double[] { (edgeStartPoints3[9] + edgeStartPoints5[23]) / 2, edgeStartPoints3[10] - 35, 0 };
                                AcadDimAligned aligned5 = modelSpace.AddDimAligned(new double[] { edgeStartPoints3[9], edgeStartPoints3[10] - 15, edgeStartPoints3[11] }, new double[] { edgeStartPoints5[21], edgeStartPoints5[22] - 15, edgeStartPoints5[23] }, textPos);
                                aligned5.TextHeight = 10;
                                aligned5.Update();

                                textPos = new double[] { (edgeStartPoints6[3] + edgeStartPoints8[21]) / 2, edgeStartPoints6[7] - 35, 0 };
                                AcadDimAligned aligned6 = modelSpace.AddDimAligned(new double[] { edgeStartPoints6[6], edgeStartPoints6[7] - 15, edgeStartPoints6[8] }, new double[] { edgeStartPoints8[21], edgeStartPoints8[22] - 15, edgeStartPoints8[23] }, textPos);
                                aligned6.TextHeight = 10;
                                aligned6.Update();

                            }
                        }
                        else
                        {
                            //调整起始点
                            startPoint = new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap, startPoint.getY(), startPoint.getZ());

                            //隐藏平盖片门边
                            edgeStartPoints3 = DrawSingleEdge(startPoint, 0, 1, 2);
                            edge2 = modelSpace.AddPolyline(edgeStartPoints3);
                            edge2.Closed = true;
                            previewImg.AddPolyLine(edgeStartPoints3);

                            //画线(窗户)
                            edgeStartPoints4 = new double[] { startPoint.getX() + hideCoverEdgeWidth, startPoint.getY() - (hideCoverEdgeHeight - hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                            edgeEndPoints4 = new double[] { startPoint.getX() + hideCoverEdgeWidth + windowWidth1, startPoint.getY() - (hideCoverEdgeHeight - hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                            modelSpace.AddLine(edgeStartPoints4, edgeEndPoints4);
                            previewImg.AddLine(edgeStartPoints4, edgeEndPoints4);

                            edgeStartPoints4 = new double[] { startPoint.getX() + hideCoverEdgeWidth, startPoint.getY() - (hideCoverEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                            edgeEndPoints4 = new double[] { startPoint.getX() + hideCoverEdgeWidth + windowWidth1, startPoint.getY() - (hideCoverEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                            modelSpace.AddLine(edgeStartPoints4, edgeEndPoints4);
                            previewImg.AddLine(edgeStartPoints4, edgeEndPoints4);
                            //平门边
                            startPoint = new Point(edgeEndPoints4[0], startPoint.getY(), startPoint.getZ());
                            edgeStartPoints5 = DrawSingleEdge(startPoint, 0, pos, 1);
                            edge3 = modelSpace.AddPolyline(edgeStartPoints5);
                            edge3.Closed = true;
                            previewImg.AddPolyLine(edgeStartPoints5);
                            
                            //平盖片门边
                            pos = -1 * pos;
                            startPoint = new Point(startPoint.getX() + plainEdgeWidth + windowGap + plainCoverEdgeWidth, startPoint.getY(), startPoint.getZ());
                            edgeStartPoints6 = DrawSingleEdge(startPoint, 0, pos, 3);
                            edge4 = modelSpace.AddPolyline(edgeStartPoints6);
                            edge4.Closed = true;
                            previewImg.AddPolyLine(edgeStartPoints6);
                            //画窗框线
                            edgeStartPoints7 = new double[] { startPoint.getX(), startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                            edgeEndPoints7 = new double[] { startPoint.getX() + windowWidth2, startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                            modelSpace.AddLine(edgeStartPoints7, edgeEndPoints7);
                            previewImg.AddLine(edgeStartPoints7, edgeEndPoints7);

                            edgeStartPoints7 = new double[] { startPoint.getX(), startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                            edgeEndPoints7 = new double[] { startPoint.getX() + windowWidth2, startPoint.getY() - (hidePlainEdgeHeight + hidePlainEdgeSlotWidth) / 2.0, startPoint.getZ() };
                            modelSpace.AddLine(edgeStartPoints7, edgeEndPoints7);
                            previewImg.AddLine(edgeStartPoints7, edgeEndPoints7);

                            //隐藏平门边
                            startPoint = new Point(startPoint.getX() + windowWidth2 + hidePlainEdgeWidth, startPoint.getY(), startPoint.getZ());
                            edgeStartPoints8 = DrawSingleEdge(startPoint, 0, pos, 0);
                            edge5 = modelSpace.AddPolyline(edgeStartPoints8);
                            edge5.Closed = true;
                            previewImg.AddPolyLine(edgeStartPoints8);
                            
                            //窗框尺寸标注
                            textPos = new double[] { (edgeStartPoints[21] + edgeStartPoints2[6]) / 2, edgeStartPoints[22] - 35, 0 };
                            AcadDimAligned aligned4 = modelSpace.AddDimAligned(new double[] { edgeStartPoints[21], edgeStartPoints[22] - 15, edgeStartPoints[23] }, new double[] { edgeStartPoints2[6], edgeStartPoints2[7] - 15, edgeStartPoints2[8] }, textPos);
                            aligned4.TextHeight = 10;
                            aligned4.Update();

                            textPos = new double[] { (edgeStartPoints3[0] + edgeStartPoints5[6]) / 2, edgeStartPoints3[19] - 35, 0 };
                            AcadDimAligned aligned5 = modelSpace.AddDimAligned(new double[] { edgeStartPoints3[0], edgeStartPoints3[19] - 15, edgeStartPoints3[2] }, new double[] { edgeStartPoints5[6], edgeStartPoints5[7] - 15, edgeStartPoints5[8] }, textPos);
                            aligned5.TextHeight = 10;
                            aligned5.Update();

                            textPos = new double[] { (edgeStartPoints6[3] + edgeStartPoints8[21]) / 2, edgeStartPoints6[7] - 35, 0 };
                            AcadDimAligned aligned6 = modelSpace.AddDimAligned(new double[] { edgeStartPoints6[3], edgeStartPoints6[7] - 15, edgeStartPoints6[2] }, new double[] { edgeStartPoints8[21], edgeStartPoints8[22] - 15, edgeStartPoints8[23] }, textPos);
                            aligned6.TextHeight = 10;
                            aligned6.Update();
                        }


                        //窗户尺寸标注
                        textPos = new double[] { (edgeStartPoints1[0] + edgeEndPoints1[0]) / 2, edgeStartPoints1[1] - 15, 0 };
                        AcadDimAligned aligned1 = modelSpace.AddDimAligned(new double[] { edgeStartPoints1[0], edgeStartPoints1[1] - 10, edgeStartPoints1[2] }, new double[] { edgeEndPoints1[0], edgeEndPoints1[1] - 10, edgeEndPoints1[2] }, textPos);
                        aligned1.TextHeight = 10;
                        aligned1.Update();

                        textPos = new double[] { (edgeStartPoints4[0] + edgeEndPoints4[0]) / 2, edgeStartPoints4[1] - 15, 0 };
                        AcadDimAligned aligned2 = modelSpace.AddDimAligned(new double[] { edgeStartPoints4[0], edgeStartPoints4[1] - 10, edgeStartPoints4[2] }, new double[] { edgeEndPoints4[0], edgeEndPoints4[1] - 10, edgeEndPoints4[2] }, textPos);
                        aligned2.TextHeight = 10;
                        aligned2.Update();

                        textPos = new double[] { (edgeStartPoints7[0] + edgeEndPoints7[0]) / 2, edgeStartPoints7[1] - 15, 0 };
                        AcadDimAligned aligned3 = modelSpace.AddDimAligned(new double[] { edgeStartPoints7[0], edgeStartPoints7[1] - 10, edgeStartPoints7[2] }, new double[] { edgeEndPoints7[0], edgeEndPoints7[1] - 10, edgeEndPoints7[2] }, textPos);
                        aligned3.TextHeight = 10;
                        aligned3.Update();


                    }
                    else
                    {

                    }
                    break;
                case 1:
                    if (windowNum == 1)
                    {
                        //右侧基准
                        //隐形平门边
                        edgeStartPoints = DrawSingleEdge(startPoint,1,-1,0);
                        edge = modelSpace.AddPolyline(edgeStartPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        //平门边
                        edgeEndPoints = DrawSingleEdge(new Point(startPoint.getX() - hidePlainEdgeWidth - windowWidth - plainEdgeWidth, startPoint.getY(), startPoint.getZ()), 1, 1, 1);
                        edge1 = modelSpace.AddPolyline(edgeEndPoints);
                        edge1.Closed = true;
                        previewImg.AddPolyLine(edgeEndPoints);
                    }
                    else if (windowNum == 2)
                    {
                        //隐形平门边
                        edgeStartPoints = DrawSingleEdge(startPoint, 1, 1, 0);
                        edge = modelSpace.AddPolyline(edgeStartPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        //平盖片门边
                        edgeStartPoints = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth, startPoint.getY(), startPoint.getZ()), 1, 1, 3);
                        edge1 = modelSpace.AddPolyline(edgeStartPoints);
                        edge1.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        //平门边
                        edgeStartPoints = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainCoverEdgeWidth + windowGap, startPoint.getY(), startPoint.getZ()), 1, 1, 3);
                        edge2 = modelSpace.AddPolyline(edgeStartPoints);
                        edge2.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        //隐形平门边
                        edgeStartPoints = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainCoverEdgeWidth + windowGap + plainEdgeWidth + windowWidth1, startPoint.getY(), startPoint.getZ()), 1, 1, 3);
                        edge3 = modelSpace.AddPolyline(edgeStartPoints);
                        edge3.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                    }
                    else if (windowNum == 3)
                    {
                        //隐形平门边
                        edgeStartPoints = DrawSingleEdge(startPoint, 1, 1, 0);
                        edge = modelSpace.AddPolyline(edgeStartPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        //平门边
                        edgeStartPoints = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth, startPoint.getY(), startPoint.getZ()), 1, 1, 1);
                        edge1 = modelSpace.AddPolyline(edgeStartPoints);
                        edge1.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        if(type == 3 || type == 4)
                        {
                            if(type == 3)
                            {
                                //平盖片门边
                                edgeStartPoints = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap, startPoint.getY(), startPoint.getZ()), 1, 1, 3);
                                edge2 = modelSpace.AddPolyline(edgeStartPoints);
                                edge2.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints);
                                //隐形平门边
                                edgeStartPoints = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap + plainCoverEdgeWidth + windowWidth1, startPoint.getY(), startPoint.getZ()), 1, 1, 0);
                                edge3 = modelSpace.AddPolyline(edgeStartPoints);
                                edge3.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints);
                                //平门边
                                edgeStartPoints = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap + plainCoverEdgeWidth + windowWidth1 + hidePlainEdgeWidth + windowGap + tbarMinWidth + windowGap, startPoint.getY(), startPoint.getZ()), 1, 1, 1);
                                edge4 = modelSpace.AddPolyline(edgeStartPoints);
                                edge4.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints);
                                //隐形平门边
                                edgeStartPoints = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap + plainCoverEdgeWidth + windowWidth1 + hidePlainEdgeWidth + windowGap + tbarMinWidth + windowGap + plainEdgeWidth + windowWidth2, startPoint.getY(), startPoint.getZ()), 1, 1, 0);
                                edge5 = modelSpace.AddPolyline(edgeStartPoints);
                                edge5.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints);
                            }
                            else
                            {
                                //平门边
                                edgeStartPoints = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap + tbarMinWidth + windowGap, startPoint.getY(), startPoint.getZ()), 1, 1, 3);
                                edge2 = modelSpace.AddPolyline(edgeStartPoints);
                                edge2.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints);
                                //隐形平门边
                                edgeStartPoints = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap + tbarMinWidth + windowGap + plainEdgeWidth + windowWidth1 + hidePlainEdgeWidth, startPoint.getY(), startPoint.getZ()), 1, -1, 0);
                                edge3 = modelSpace.AddPolyline(edgeStartPoints);
                                edge3.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints);
                                //平门边
                                edgeStartPoints = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap + tbarMinWidth + windowGap + plainEdgeWidth + windowWidth1 + hidePlainEdgeWidth + windowGap + tbarMinWidth + windowGap, startPoint.getY(), startPoint.getZ()), 1, 1, 1);
                                edge4 = modelSpace.AddPolyline(edgeStartPoints);
                                edge4.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints);
                                //隐形平门边
                                edgeStartPoints = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap + tbarMinWidth + windowGap + plainEdgeWidth + windowWidth1 + hidePlainEdgeWidth + windowGap + tbarMinWidth + windowGap + plainEdgeWidth + windowWidth2 + hidePlainEdgeWidth, startPoint.getY(), startPoint.getZ()), 1, -1, 0);
                                edge5 = modelSpace.AddPolyline(edgeStartPoints);
                                edge5.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints);
                            }
                        }
                        else
                        {
                            //隐形平盖片门边
                            edgeStartPoints = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap, startPoint.getY(), startPoint.getZ()), 1, 1, 2);
                            edge2 = modelSpace.AddPolyline(edgeStartPoints);
                            edge2.Closed = true;
                            previewImg.AddPolyLine(edgeStartPoints);
                            //平门边
                            edgeStartPoints = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap + hideCoverEdgeWidth + windowWidth1, startPoint.getY(), startPoint.getZ()), 1, 1, 1);
                            edge3 = modelSpace.AddPolyline(edgeStartPoints);
                            edge3.Closed = true;
                            previewImg.AddPolyLine(edgeStartPoints);
                            //平盖片门边
                            edgeStartPoints = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap + hideCoverEdgeWidth + windowWidth1 + plainEdgeWidth + windowGap, startPoint.getY(), startPoint.getZ()), 1, 1, 3);
                            edge4 = modelSpace.AddPolyline(edgeStartPoints);
                            edge4.Closed = true;
                            previewImg.AddPolyLine(edgeStartPoints);
                            //隐形平门边
                            edgeStartPoints = DrawSingleEdge(new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap + hideCoverEdgeWidth + windowWidth1 + plainEdgeWidth + windowGap + plainCoverEdgeWidth + windowWidth2, startPoint.getY(), startPoint.getZ()), 1, 1, 0);
                            edge5 = modelSpace.AddPolyline(edgeStartPoints);
                            edge5.Closed = true;
                            previewImg.AddPolyLine(edgeStartPoints);
                        }
                        
                    }
                    else
                    {

                    }
                    break;
                case 2:
                    break;
            }
        }
        
        
        //画上下固定板
        public void DrawBoard(Point startPoint, int view)
        {
            int pos = 1;
            double[] edgeStartPoints, edgeEndPoints, textPos;
            double x_offset, y_offset;
            AcadPolyline edge,edge1;

            double singleBladeWidth = (upperLBoardLength - (boardSlotDept * 2)) / (bladeNum / windowNum);
            //y_offset = (int)((bladeNum / windowNum) * singleBladeWidth);
            
            switch (view)
            {
                case 0:
                    break;
                case 1:
                    if (windowNum == 1)
                    {
                        y_offset = hidePlainEdgeLength - lowerBoardWidth;
                        edgeStartPoints = DrawSingleBoard(startPoint, 1, pos);
                        edge = modelSpace.AddPolyline(edgeStartPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        edgeEndPoints = DrawSingleBoard(new Point(startPoint.getX(), startPoint.getY() - y_offset, startPoint.getZ()), 1, pos);
                        edge = modelSpace.AddPolyline(edgeEndPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeEndPoints);
                    }
                    else if (windowNum == 2)
                    {
                        y_offset = hidePlainEdgeLength - lowerBoardWidth;
                        //左半部分
                        edgeStartPoints = DrawSingleBoard(startPoint, 1, pos);
                        edge = modelSpace.AddPolyline(edgeStartPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        edgeEndPoints = DrawSingleBoard(new Point(startPoint.getX(), startPoint.getY() - y_offset, startPoint.getZ()), 1, pos);
                        edge = modelSpace.AddPolyline(edgeEndPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeEndPoints);
                        //右半部份
                        x_offset = windowWidth + plainCoverEdgeWidth + windowGap + plainEdgeWidth;
                        edgeStartPoints = DrawSingleBoard(new Point(startPoint.getX() + x_offset, startPoint.getY(), startPoint.getZ()), 1, pos,1);
                        edge = modelSpace.AddPolyline(edgeStartPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        edgeEndPoints = DrawSingleBoard(new Point(startPoint.getX() + x_offset, startPoint.getY() - y_offset, startPoint.getZ()), 1, pos,1);
                        edge = modelSpace.AddPolyline(edgeEndPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeEndPoints);
                    }
                    else if (windowNum == 3)
                    {
                        int flag = 0;
                        y_offset = hidePlainEdgeLength - lowerBoardWidth;
                        //左半部分
                        edgeStartPoints = DrawSingleBoard(startPoint, 1, pos,flag);
                        edge = modelSpace.AddPolyline(edgeStartPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        edgeEndPoints = DrawSingleBoard(new Point(startPoint.getX(), startPoint.getY() - y_offset, startPoint.getZ()), 1, pos,flag);
                        edge = modelSpace.AddPolyline(edgeEndPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeEndPoints);
                        //中间部分
                        if(type == 4)
                        {
                            flag = 1;
                            x_offset = windowWidth + plainEdgeWidth + plainEdgeWidth + windowGap + tbarMinWidth + windowGap;
                        }
                        else
                        {
                            x_offset = windowWidth + plainEdgeWidth + hideCoverEdgeWidth + windowGap;
                        }
                        edgeStartPoints = DrawSingleBoard(new Point(startPoint.getX() + x_offset, startPoint.getY(), startPoint.getZ()), 1, pos,flag);
                        edge = modelSpace.AddPolyline(edgeStartPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        edgeEndPoints = DrawSingleBoard(new Point(startPoint.getX() + x_offset, startPoint.getY() - y_offset, startPoint.getZ()), 1, pos,flag);
                        edge = modelSpace.AddPolyline(edgeEndPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeEndPoints);

                        //右半部份
                        if (type == 3 || type == 4)
                        {
                            flag = 2;
                            if (type == 3)
                            {
                                x_offset = windowWidth + plainEdgeWidth + plainCoverEdgeWidth + windowGap + windowWidth1 + hidePlainEdgeWidth + windowGap + tbarMinWidth  + plainEdgeWidth + windowGap;
                            }
                            else
                            {
                                x_offset = windowWidth + plainEdgeWidth + plainEdgeWidth + windowGap + tbarMinWidth + windowGap + windowWidth1 + hidePlainEdgeWidth + windowGap + tbarMinWidth + plainEdgeWidth + windowGap;
                            }
                        }
                        else
                        {
                            //右半部份
                            x_offset = windowWidth + plainEdgeWidth + hideCoverEdgeWidth + windowGap + windowWidth1 + plainEdgeWidth + plainCoverEdgeWidth + windowGap;
                        }
                        edgeStartPoints = DrawSingleBoard(new Point(startPoint.getX() + x_offset, startPoint.getY(), startPoint.getZ()), 1, pos,flag);
                        edge = modelSpace.AddPolyline(edgeStartPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        edgeEndPoints = DrawSingleBoard(new Point(startPoint.getX() + x_offset, startPoint.getY() - y_offset, startPoint.getZ()), 1, pos,flag);
                        edge = modelSpace.AddPolyline(edgeEndPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeEndPoints);

                    }
                    else
                    {

                    }
                    break;
                case 2:
                    //画上板
                    edgeStartPoints = DrawSingleBoard(startPoint, 2, 1);
                    edge = modelSpace.AddPolyline(edgeStartPoints);
                    edge.Closed = true;
                    previewImg.AddPolyLine(edgeStartPoints);
                    //画下板
                    x_offset = lowerBoardHeight;
                    y_offset = hidePlainEdgeLength;
                    startPoint = new Point(startPoint.getX() + x_offset, startPoint.getY() - y_offset, startPoint.getZ());
                    edgeEndPoints = DrawSingleBoard(startPoint, 2, -1);
                    edge1 = modelSpace.AddPolyline(edgeEndPoints);
                    edge1.Closed = true;
                    previewImg.AddPolyLine(edgeEndPoints);
                    //画线
                    edgeStartPoints = new double[]{startPoint.getX(),startPoint.getY(),startPoint.getZ() };
                    edgeEndPoints = new double[] { startPoint.getX(), startPoint.getY() + y_offset, startPoint.getZ() };
                    modelSpace.AddLine(edgeStartPoints,edgeEndPoints);
                    previewImg.AddLine(edgeStartPoints,edgeEndPoints);

                    //尺寸标注
                    textPos = new double[] { startPoint.getX() + 25, (startPoint.getY() + startPoint.getY() - upperBoardWidth + 2 * y_offset) / 2, 0 };
                    AcadDimRotated dimRoated1 = modelSpace.AddDimRotated(new double[] { startPoint.getX(), startPoint.getY() + y_offset, startPoint.getZ() }, new double[] { startPoint.getX(), startPoint.getY() + y_offset - upperBoardWidth, startPoint.getZ() }, textPos, -Math.PI / 2);
                    dimRoated1.TextHeight = 10;
                    dimRoated1.Update();

                    textPos = new double[] { startPoint.getX() + 45, (startPoint.getY() + startPoint.getY() + y_offset) / 2, 0 };
                    AcadDimRotated dimRoated2 = modelSpace.AddDimRotated(new double[] { startPoint.getX(), startPoint.getY() + y_offset, startPoint.getZ() }, new double[] { startPoint.getX(), startPoint.getY(), startPoint.getZ() }, textPos, -Math.PI / 2);
                    dimRoated2.TextHeight = 10;
                    dimRoated2.Update();
                    break;
                default:
                    break;
            }
        }
        //画叶片
        public void DrawLeaf(Point startPoint, int view)
        {
            double centerX, centerY, centerZ, mainAxisX, mainAxisY, subAxisX, subAxisY;
            double[] edgeStartPoints, edgeMidPoints, edgeEndPoints,textPos;
            int singleBladeNum = (bladeNum / windowNum);
            //double singleBladeWidth = (hidePlainEdgeLength - (upperBoardWidth + lowerBoardWidth - (boardSlotDept * 2))) / singleBladeNum;
            double singleBladeWidth = (hidePlainEdgeLength - (upperBoardWidth + lowerBoardWidth)) / singleBladeNum;
            double angle = Math.Asin(upperBoardHeight / bladeWidth) * 180 / Math.PI;

            double singleBladeHeight = bladeHeight * Math.Cos(angle);
            //长短轴比率
            double ratio = bladeHeight / bladeWidth;
            //初始化中心坐标
            centerX = startPoint.getX() + upperBoardHeight / 2.0;
            centerY = startPoint.getY() - (upperBoardWidth - boardSlotDept) - (singleBladeWidth / 2.0);
            centerZ = startPoint.getZ();

            //mainAxisX = centerX + (bladeWidth / 2.0) * Math.Sin(angle);
            //mainAxisY = centerY - (singleBladeWidth / 2.0);

            //subAxisX = centerX + Math.Cos(angle) * (bladeHeight / 2.0);
            //subAxisY = centerY + Math.Sin(angle) * (bladeHeight / 2.0);

            double x_offset = 0.0, y_offset = 0.0;

            AcadPolyline edge,edge1,edge2;
            AcadEllipse ellipse;
            switch (view)
            {
                case 0:
                    break;
                case 1:
                    if (windowNum == 1)
                    {
                        for (int i = 0; i < singleBladeNum; i++)
                        {
                            edgeStartPoints = DrawSingleLeaf(new Point(startPoint.getX(),startPoint.getY() - i * singleBladeWidth,startPoint.getZ()), 1, 1);
                            edge = modelSpace.AddPolyline(edgeStartPoints);
                            edge.Closed = true;
                            previewImg.AddPolyLine(edgeStartPoints);
                        }
                        if(isWindow1Part == 1)
                        {
                            DrawWindowPart(startPoint, 1, 1, singleBladeWidth);
                        }
                    }
                    else if (windowNum == 2)
                    {
                        for (int i = 0; i < singleBladeNum; i++)
                        { 
                            edgeStartPoints = DrawSingleLeaf(new Point(startPoint.getX(), startPoint.getY() - i * singleBladeWidth, startPoint.getZ()), 1, 1);
                            edge = modelSpace.AddPolyline(edgeStartPoints);
                            edge.Closed = true;
                            previewImg.AddPolyLine(edgeStartPoints);
                        }
                        if (isWindow1Part == 1)
                        {
                            DrawWindowPart(startPoint, 1, 1, singleBladeWidth);
                        }
                        x_offset = windowWidth + plainCoverEdgeWidth + windowGap + plainEdgeWidth;
                        
                        for (int i = 0; i < singleBladeNum; i++)
                        {
                            edgeEndPoints = DrawSingleLeaf(new Point(startPoint.getX() + x_offset, startPoint.getY() - i * singleBladeWidth, startPoint.getZ()), 1, 1);
                            edge1 = modelSpace.AddPolyline(edgeEndPoints);
                            edge1.Closed = true;
                            previewImg.AddPolyLine(edgeEndPoints);
                        }
                        if (isWindow2Part == 1)
                        {
                            DrawWindowPart(new Point(startPoint.getX() + x_offset,startPoint.getY(),startPoint.getZ()), 1, 2, singleBladeWidth);
                        }
                    }
                    else if (windowNum == 3)
                    {
                        int flag = 0;
                        //左侧
                        for (int i = 0; i < singleBladeNum; i++)
                        {
                            edgeStartPoints = DrawSingleLeaf(new Point(startPoint.getX(), startPoint.getY() - i * singleBladeWidth, startPoint.getZ()), 1, 1, flag);
                            edge = modelSpace.AddPolyline(edgeStartPoints);
                            edge.Closed = true;
                            previewImg.AddPolyLine(edgeStartPoints);
                        }
                        if (isWindow1Part == 1)
                        {
                            DrawWindowPart(startPoint, 1, 1, singleBladeWidth);
                        }
                        //中间 
                        x_offset = windowWidth + hideCoverEdgeWidth + plainEdgeWidth + windowGap;
                        //偏移量
                        if (type == 4)
                        {
                            flag = 1;
                            x_offset = windowWidth + plainEdgeWidth + plainEdgeWidth + windowGap + tbarMinWidth + windowGap;
                        }
                        for (int i = 0; i < singleBladeNum; i++)
                        {
                            edgeMidPoints = DrawSingleLeaf(new Point(startPoint.getX() + x_offset, startPoint.getY() - i * singleBladeWidth, startPoint.getZ()), 1, 1, flag);
                            edge1 = modelSpace.AddPolyline(edgeMidPoints);
                            edge1.Closed = true;
                            previewImg.AddPolyLine(edgeMidPoints);
                        }
                        if (isWindow2Part == 1)
                        {
                            DrawWindowPart(new Point(startPoint.getX() + x_offset, startPoint.getY(), startPoint.getZ()), 1, 2, singleBladeWidth);
                        }
                        //右侧
                        x_offset = windowWidth + hideCoverEdgeWidth + plainEdgeWidth + windowGap + windowWidth1 + plainCoverEdgeWidth + plainEdgeWidth + windowGap;
                        if (type == 3 || type == 4)
                        {
                            flag = 2;
                            if(type == 3)
                            {
                                x_offset = windowWidth + plainEdgeWidth + plainCoverEdgeWidth + windowGap + windowWidth1 + hidePlainEdgeWidth + windowGap + tbarMinWidth + plainEdgeWidth + windowGap;
                            }
                            else
                            {
                                x_offset = windowWidth + plainEdgeWidth + plainEdgeWidth + windowGap + tbarMinWidth + windowGap + windowWidth1 + hidePlainEdgeWidth + windowGap + tbarMinWidth + plainEdgeWidth + windowGap;
                            }
                        }

                        for (int i = 0; i < singleBladeNum; i++)
                        {
                            edgeEndPoints = DrawSingleLeaf(new Point(startPoint.getX() + x_offset, startPoint.getY() - i * singleBladeWidth, startPoint.getZ()), 1, 1,flag);
                            edge2 = modelSpace.AddPolyline(edgeEndPoints);
                            edge2.Closed = true;
                            previewImg.AddPolyLine(edgeEndPoints);
                        }
                        if (isWindow3Part == 1)
                        {
                            DrawWindowPart(new Point(startPoint.getX() + x_offset, startPoint.getY(), startPoint.getZ()), 1, 3, singleBladeWidth);
                        }
                    }
                    break;
                case 2:
                    if (windowNum == 1)
                    {
                        y_offset = 103.02;
                        centerY = startPoint.getY() - y_offset;
                        singleBladeWidth = 50.8;
                    }
                    else if(windowNum == 2)
                    {
                        y_offset = 106.32;
                        centerY = startPoint.getY() - y_offset;
                        singleBladeWidth = 50.8;
                    }
                    else if(windowNum == 3)
                    {
                        y_offset = 111.72;
                        singleBladeWidth = 50.8;
                        if(type == 3 || type == 4)
                        {
                            if(type == 3)
                            {
                                y_offset = 133.87;
                                singleBladeWidth = 63.5;
                            }
                            else
                            {
                                y_offset = 118.62;
                                singleBladeWidth = 63.5;
                            }
                        }
                        centerY = startPoint.getY() - y_offset;

                    }
                    for (int i = 0; i < singleBladeNum; i++)
                    {
                        //中心点
                        edgeStartPoints = new double[] { centerX, centerY - i * singleBladeWidth, centerZ };
                        edgeMidPoints = new double[] { (bladeWidth / 2),  (bladeHeight / 2), centerZ };
                        //长轴半径长，短轴半径长
                        edgeEndPoints = new double[] {
                                bladeWidth / 2.0,centerZ, centerZ
                        };
                        //Console.WriteLine(angle);
                        ellipse = modelSpace.AddEllipse(edgeStartPoints, edgeEndPoints, ratio);
                        ellipse.Rotate(edgeStartPoints, (90 - angle) * Math.PI / 180);
                        previewImg.AddEllipse(edgeMidPoints, edgeEndPoints,edgeStartPoints,bladeWidth,bladeHeight ,angle);
                        //centerY -= i * singleBladeWidth;
                    }

                    //尺寸标注
                    //y_offset = hidePlainEdgeLength;
                    x_offset = upperBoardHeight;

                    textPos = new double[] { startPoint.getX() + upperBoardHeight + 40, (centerY + y_offset + centerY) / 2, 0 };
                    AcadDimRotated dimRotated1 = modelSpace.AddDimRotated(new double[] { startPoint.getX() + upperBoardHeight, centerY, startPoint.getZ() }, new double[] { startPoint.getX() + upperBoardHeight, centerY + y_offset, startPoint.getZ() }, textPos, -Math.PI / 2);
                    dimRotated1.TextHeight = 10;
                    dimRotated1.Update();
                    AcadDimOrdinate dimOrd = modelSpace.AddDimOrdinate(new double[] { centerX, centerY, centerZ }, new double[] { centerX - 45, centerY - singleBladeWidth, centerZ }, 0);
                    dimOrd.TextOverride = " 叶片 * " + singleBladeNum.ToString();
                    dimOrd.TextHeight = 10;
                    dimOrd.Update();
                    break;
                default:
                    break;
            }
        }

        //画铰链
        public void DrawHinge(Point startPoint, int view)
        {
            double[] edgeStartPoints, edgeEndPoints, edgeStartPoints1, edgeEndPoints1, edgeStartPoints2, edgeEndPoints2, textPos,textPos1,textPos2;
            AcadPolyline edge, edge1,edge2, edge3, edge4, edge5;
            switch (view)
            {
                case 0:
                    break;
                case 1:
                    if (windowNum == 1)
                    {
                        startPoint = new Point(startPoint.getX(),startPoint.getY() - hingeUpDis1,startPoint.getZ());
                        edgeStartPoints = DrawSingleHinge(startPoint, 1, -1);
                        edge = modelSpace.AddPolyline(edgeStartPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        startPoint = new Point(startPoint.getX(), startPoint.getY() - (hingeDownDis1 - hingeUpDis1), startPoint.getZ());
                        edgeEndPoints = DrawSingleHinge(startPoint, 1, -1);
                        edge1 = modelSpace.AddPolyline(edgeEndPoints);
                        edge1.Closed = true;
                        previewImg.AddPolyLine(edgeEndPoints);
                        //窗户尺寸标注
                        textPos = new double[] { (edgeStartPoints[0] + edgeEndPoints[0]) / 2, edgeStartPoints[1] + 10, 0 };
                        AcadDimAligned aligned1 = modelSpace.AddDimAligned(new double[] { edgeStartPoints[0], edgeStartPoints[1], edgeStartPoints[2] }, new double[] { edgeStartPoints[3], edgeStartPoints[4], edgeStartPoints[5] }, textPos);
                        aligned1.TextHeight = 10;
                        aligned1.Update();
                        textPos1 = new double[] { edgeEndPoints[3] - 10, (edgeStartPoints[4] + edgeEndPoints[7]) / 2, 0 };
                        AcadDimAligned aligned2 = modelSpace.AddDimAligned(new double[] { edgeStartPoints[3], edgeStartPoints[4], edgeStartPoints[5] }, new double[] { edgeStartPoints[6], edgeStartPoints[7], edgeStartPoints[8] }, textPos1);
                        aligned2.TextHeight = 10;
                        aligned2.Update();
                    }
                    else if (windowNum == 2)
                    {
                        //左
                        startPoint = new Point(startPoint.getX(), startPoint.getY() - hingeUpDis1, startPoint.getZ());
                        edgeStartPoints = DrawSingleHinge(startPoint, 1, 1);
                        edge = modelSpace.AddPolyline(edgeStartPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        startPoint = new Point(startPoint.getX(), startPoint.getY() - (hingeDownDis1 - hingeUpDis1), startPoint.getZ());
                        edgeEndPoints = DrawSingleHinge(startPoint, 1, 1);
                        edge1 = modelSpace.AddPolyline(edgeEndPoints);
                        edge1.Closed = true;
                        previewImg.AddPolyLine(edgeEndPoints);
                        //窗户尺寸标注
                        textPos = new double[] { (edgeStartPoints[0] + edgeEndPoints[0]) / 2, edgeStartPoints[1] + 10, 0 };
                        AcadDimAligned aligned1 = modelSpace.AddDimAligned(new double[] { edgeStartPoints[0], edgeStartPoints[1], edgeStartPoints[2] }, new double[] { edgeStartPoints[3], edgeStartPoints[4], edgeStartPoints[5] }, textPos);
                        aligned1.TextHeight = 10;
                        aligned1.Update();
                        textPos1 = new double[] { edgeStartPoints[3] + 15, (edgeStartPoints[4] + edgeEndPoints[7]) / 2, 0 };
                        AcadDimAligned aligned2 = modelSpace.AddDimAligned(new double[] { edgeStartPoints[3], edgeStartPoints[4], edgeStartPoints[5] }, new double[] { edgeStartPoints[6], edgeStartPoints[7], edgeStartPoints[8] }, textPos1);
                        aligned2.TextHeight = 10;
                        aligned2.Update();

                        //右
                        startPoint = new Point(startPoint.getX() + upperLBoardLength - (lboardLHeight2*2) - (windowGap * 2), startPoint.getY() + hingeDownDis1 - hingeUpDis2, startPoint.getZ());
                        edgeStartPoints1 = DrawSingleHinge(startPoint, 1, -1);
                        edge2 = modelSpace.AddPolyline(edgeStartPoints1);
                        edge2.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints1);
                        startPoint = new Point(startPoint.getX(), startPoint.getY() - (hingeDownDis2 - hingeUpDis2), startPoint.getZ());
                        edgeEndPoints2 = DrawSingleHinge(startPoint, 1, -1);
                        edge3 = modelSpace.AddPolyline(edgeEndPoints2);
                        edge3.Closed = true;
                        previewImg.AddPolyLine(edgeEndPoints2);
                    }
                    else if (windowNum == 3)
                    {
                        //左
                        startPoint = new Point(startPoint.getX(), startPoint.getY() - hingeUpDis1, startPoint.getZ());
                        edgeStartPoints = DrawSingleHinge(startPoint, 1, 1);
                        edge = modelSpace.AddPolyline(edgeStartPoints);
                        edge.Closed = true;
                        previewImg.AddPolyLine(edgeStartPoints);
                        startPoint = new Point(startPoint.getX(), startPoint.getY() - (hingeDownDis1 - hingeUpDis1), startPoint.getZ());
                        edgeEndPoints = DrawSingleHinge(startPoint, 1, 1);
                        edge1 = modelSpace.AddPolyline(edgeEndPoints);
                        edge1.Closed = true;
                        previewImg.AddPolyLine(edgeEndPoints);

                        //窗户尺寸标注
                        textPos = new double[] { (edgeStartPoints[0] + edgeEndPoints[0]) / 2, edgeStartPoints[1] + 10, 0 };
                        AcadDimAligned aligned1 = modelSpace.AddDimAligned(new double[] { edgeStartPoints[0], edgeStartPoints[1], edgeStartPoints[2] }, new double[] { edgeStartPoints[3], edgeStartPoints[4], edgeStartPoints[5] }, textPos);
                        aligned1.TextHeight = 10;
                        aligned1.Update();
                        textPos1 = new double[] { edgeStartPoints[3] + 15, (edgeStartPoints[4] + edgeEndPoints[7]) / 2, 0 };
                        AcadDimAligned aligned2 = modelSpace.AddDimAligned(new double[] { edgeStartPoints[3], edgeStartPoints[4], edgeStartPoints[5] }, new double[] { edgeStartPoints[6], edgeStartPoints[7], edgeStartPoints[8] }, textPos1);
                        aligned2.TextHeight = 10;
                        aligned2.Update();
                        //中
                        if(type == 3 || type == 4)
                        {
                            if(type == 3)
                            {
                                startPoint = new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap + plainCoverEdgeWidth + windowWidth1 + hidePlainEdgeWidth, startPoint.getY() + hingeDownDis1 - hingeUpDis2, startPoint.getZ());
                                edgeStartPoints1 = DrawSingleHinge(startPoint, 1, -1);
                                edge2 = modelSpace.AddPolyline(edgeStartPoints1);
                                edge2.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints1);
                                startPoint = new Point(startPoint.getX(), startPoint.getY() - (hingeDownDis2 - hingeUpDis2), startPoint.getZ());
                                edgeEndPoints1 = DrawSingleHinge(startPoint, 1, -1);
                                edge3 = modelSpace.AddPolyline(edgeEndPoints1);
                                edge3.Closed = true;
                                previewImg.AddPolyLine(edgeEndPoints1);
                            }
                            else
                            {
                                startPoint = new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap +tbarMinWidth + windowGap+ plainEdgeWidth + windowWidth1 + hidePlainEdgeWidth, startPoint.getY() + hingeDownDis1 - hingeUpDis2, startPoint.getZ());
                                edgeStartPoints1 = DrawSingleHinge(startPoint, 1, -1);
                                edge2 = modelSpace.AddPolyline(edgeStartPoints1);
                                edge2.Closed = true;
                                previewImg.AddPolyLine(edgeStartPoints1);
                                startPoint = new Point(startPoint.getX(), startPoint.getY() - (hingeDownDis2 - hingeUpDis2), startPoint.getZ());
                                edgeEndPoints1 = DrawSingleHinge(startPoint, 1, -1);
                                edge3 = modelSpace.AddPolyline(edgeEndPoints1);
                                edge3.Closed = true;
                                previewImg.AddPolyLine(edgeEndPoints1);
                            }
                        }
                        else
                        {
                            startPoint = new Point(startPoint.getX() + hidePlainEdgeWidth + windowWidth + plainEdgeWidth + windowGap, startPoint.getY() + hingeDownDis1 - hingeUpDis2, startPoint.getZ());
                            edgeStartPoints1 = DrawSingleHinge(startPoint, 1, 1);
                            edge2 = modelSpace.AddPolyline(edgeStartPoints1);
                            edge2.Closed = true;
                            previewImg.AddPolyLine(edgeStartPoints1);
                            startPoint = new Point(startPoint.getX(), startPoint.getY() - (hingeDownDis2 - hingeUpDis2), startPoint.getZ());
                            edgeEndPoints1 = DrawSingleHinge(startPoint, 1, 1);
                            edge3 = modelSpace.AddPolyline(edgeEndPoints1);
                            edge3.Closed = true;
                            previewImg.AddPolyLine(edgeEndPoints1);
                        }

                        //右
                        if (type != 3 && type != 4)
                        {
                            startPoint = new Point(startPoint.getX() - (hidePlainEdgeWidth + windowWidth + plainEdgeWidth) + upperLBoardLength - (lboardLHeight2 * 2) - (windowGap * 2), startPoint.getY() + hingeDownDis2 - hingeUpDis3, startPoint.getZ());
                            edgeStartPoints2 = DrawSingleHinge(startPoint, 1, -1);
                            edge4 = modelSpace.AddPolyline(edgeStartPoints2);
                            edge4.Closed = true;
                            previewImg.AddPolyLine(edgeStartPoints2);
                            startPoint = new Point(startPoint.getX(), startPoint.getY() - (hingeDownDis3 - hingeUpDis3), startPoint.getZ());
                            edgeEndPoints2 = DrawSingleHinge(startPoint, 1, -1);
                            edge5 = modelSpace.AddPolyline(edgeEndPoints2);
                            edge5.Closed = true;
                            previewImg.AddPolyLine(edgeEndPoints2);
                        }
                        else
                        {
                            startPoint = new Point(startPoint.getX() + windowGap * 2 + tbarMinWidth + plainEdgeWidth + windowWidth2 + hidePlainEdgeWidth, startPoint.getY() + hingeDownDis2 - hingeUpDis3, startPoint.getZ());
                            edgeStartPoints2 = DrawSingleHinge(startPoint, 1, -1);
                            edge4 = modelSpace.AddPolyline(edgeStartPoints2);
                            edge4.Closed = true;
                            previewImg.AddPolyLine(edgeStartPoints2);
                            startPoint = new Point(startPoint.getX(), startPoint.getY() - (hingeDownDis3 - hingeUpDis3), startPoint.getZ());
                            edgeEndPoints2 = DrawSingleHinge(startPoint, 1, -1);
                            edge5 = modelSpace.AddPolyline(edgeEndPoints2);
                            edge5.Closed = true;
                            previewImg.AddPolyLine(edgeEndPoints2);
                        }

                    }
                    else
                    {

                    }
                    break;
                case 2:
                    break;
                default :
                    break;
            }
        }

        //画T柱单体
        public double[] DrawTBar(Point startPoint, int view)
        {
            double[] points;
            if(view == 0)
            {
                points = new double[] {startPoint.getX(),startPoint.getY(),startPoint.getZ(),
                startPoint.getX() + tbarMaxWidth,startPoint.getY(),startPoint.getZ(),
                startPoint.getX() + tbarMaxWidth,startPoint.getY() - (tbarHeight - tbarCornerHeight),startPoint.getZ(),
                startPoint.getX() + tbarMinWidth + ((tbarMaxWidth - tbarMinWidth) / 2),startPoint.getY() - (tbarHeight - tbarCornerHeight),startPoint.getZ(),
                startPoint.getX() + tbarMinWidth + ((tbarMaxWidth - tbarMinWidth) / 2),startPoint.getY() - tbarHeight,startPoint.getZ(),
                startPoint.getX()  + ((tbarMaxWidth - tbarMinWidth) / 2),startPoint.getY() - tbarHeight,startPoint.getZ(),
                startPoint.getX()  + ((tbarMaxWidth - tbarMinWidth) / 2),startPoint.getY() - (tbarHeight - tbarCornerHeight),startPoint.getZ(),
                startPoint.getX(),startPoint.getY() - (tbarHeight - tbarCornerHeight),startPoint.getZ(),
                };
                return points;
            }
            else if(view == 1)
            {
                points = new double[] {startPoint.getX(),startPoint.getY(),startPoint.getZ(),
                    startPoint.getX() + tbarMinWidth,startPoint.getY(),startPoint.getZ(),
                    startPoint.getX() + tbarMinWidth,startPoint.getY() - tbarLength,startPoint.getZ(),
                    startPoint.getX(),startPoint.getY() - tbarLength,startPoint.getZ(),
                };
                return points;
            }
            else
            {
                points = new double[] { };
                return points;
            }
        }

        //画L框单体
        public double[] DrawDoubleLSlot(Point startPoint, int view, int pos)
        {
            double[] points;
            switch (view)
            {
                case 0:
                    points = new double[]{
                        startPoint.getX(),startPoint.getY(),startPoint.getZ(),
                        startPoint.getX() + (double)pos * upperLBoardWidth,startPoint.getY(),startPoint.getZ(),//2
                        startPoint.getX() + (double)pos * upperLBoardWidth,startPoint.getY() - (lboardLHeight - lboardSlotWidth) / 2.0,startPoint.getZ(), //3
                        startPoint.getX() + (double)pos * upperLBoardWidth - ((double)pos * lboardSlotDept),startPoint.getY() - (lboardLHeight - lboardSlotWidth) / 2.0,startPoint.getZ(), //4
                        startPoint.getX() + (double)pos * upperLBoardWidth - ((double)pos * lboardSlotDept),startPoint.getY() - (lboardLHeight - lboardSlotWidth) / 2.0 - lboardSlotWidth,startPoint.getZ(), //5
                        startPoint.getX() + (double)pos * upperLBoardWidth,startPoint.getY() - (lboardLHeight - lboardSlotWidth) / 2.0 - lboardSlotWidth,startPoint.getZ(),//6
                        startPoint.getX() + (double)pos * upperLBoardWidth,startPoint.getY() - lboardLHeight,startPoint.getZ(),//7
                        startPoint.getX() + (double)pos * lboardLHeight2,startPoint.getY() - lboardLHeight ,startPoint.getZ(),//8
                        startPoint.getX() + (double)pos * lboardLHeight2,startPoint.getY() - upperLBoardHeight ,startPoint.getZ(),//9
                        startPoint.getX() + (double)pos * ((lboardLHeight2 - lboardSlotWidth) / 2.0 + lboardSlotWidth),startPoint.getY() - upperLBoardHeight ,startPoint.getZ(),//10
                        startPoint.getX() + (double)pos * ((lboardLHeight2 - lboardSlotWidth) / 2.0 + lboardSlotWidth),startPoint.getY() - (upperLBoardHeight - lboardSlotDept),startPoint.getZ(), //11

                        startPoint.getX() + (double)pos * ((lboardLHeight2 - lboardSlotWidth) / 2.0) ,startPoint.getY() - (upperLBoardHeight - lboardSlotDept) ,startPoint.getZ(),//12
                        startPoint.getX() + (double)pos * ((lboardLHeight2 - lboardSlotWidth) / 2.0),startPoint.getY() - upperLBoardHeight ,startPoint.getZ(),//13
                        startPoint.getX(),startPoint.getY() - upperLBoardHeight,startPoint.getZ()//14
                     };
                    return points;
                case 1:
                    points = new double[] { };
                    return points;
                case 2:
                    if (windowNum <= 1)
                    {
                        points = new double[] {
                             startPoint.getX(),startPoint.getY(),startPoint.getZ(), //1
                             startPoint.getX() + upperLBoardHeight,startPoint.getY(),startPoint.getZ(),//2
                             startPoint.getX() + upperLBoardHeight,startPoint.getY() - ((lboardLHeight2 - lboardSlotWidth) / 2.0),startPoint.getZ(),//3
                             startPoint.getX() + upperLBoardHeight - lboardSlotDept,startPoint.getY() - ((lboardLHeight2 - lboardSlotWidth) / 2.0),startPoint.getZ(),//4

                             startPoint.getX() + upperLBoardHeight - lboardSlotDept,startPoint.getY() - (((lboardLHeight2 - lboardSlotWidth) / 2.0) + lboardSlotWidth),startPoint.getZ(),//5
                             startPoint.getX() + upperLBoardHeight ,startPoint.getY() - (((lboardLHeight2 - lboardSlotWidth) / 2.0) + lboardSlotWidth),startPoint.getZ(),//6
                             startPoint.getX() + upperLBoardHeight ,startPoint.getY() - lboardLHeight2,startPoint.getZ(),//7

                             startPoint.getX() + lboardLHeight ,startPoint.getY() - lboardLHeight2,startPoint.getZ(),//8
                             startPoint.getX() + lboardLHeight ,startPoint.getY() - upperLBoardWidth,startPoint.getZ(),//9

                             startPoint.getX() + lboardSlotWidth + ((lboardLHeight - lboardSlotWidth) / 2.0) ,startPoint.getY() - upperLBoardWidth,startPoint.getZ(),//10
                             startPoint.getX() + lboardSlotWidth + ((lboardLHeight - lboardSlotWidth) / 2.0) ,startPoint.getY() - (upperLBoardWidth - lboardSlotDept),startPoint.getZ(),//11

                             startPoint.getX() + ((lboardLHeight - lboardSlotWidth) / 2.0) ,startPoint.getY() - (upperLBoardWidth - lboardSlotDept),startPoint.getZ(),//12
                             startPoint.getX() + ((lboardLHeight - lboardSlotWidth) / 2.0) ,startPoint.getY() - upperLBoardWidth,startPoint.getZ(),//13
                             startPoint.getX(),startPoint.getY() - upperLBoardWidth,startPoint.getZ()//14
                       };
                    }
                    else
                    {
                        points = new double[] {
                            startPoint.getX(),startPoint.getY(),startPoint.getZ(), //1
                            startPoint.getX() + upperLBoardHeight,startPoint.getY(),startPoint.getZ(),//2
                            startPoint.getX() + upperLBoardHeight,startPoint.getY() - (double)pos * lboardLHeight2,startPoint.getZ(),//3
                            startPoint.getX() + lboardLHeight,startPoint.getY() - (double)pos *  lboardLHeight2,startPoint.getZ(),//4
                            startPoint.getX() + lboardLHeight,startPoint.getY()  - (double)pos *  upperLBoardWidth,startPoint.getZ(),//5
                            startPoint.getX() + ((lboardLHeight + lboardSlotWidth) / 2.0),startPoint.getY() - (double)pos *  upperLBoardWidth,startPoint.getZ(),//6
                            startPoint.getX() + ((lboardLHeight + lboardSlotWidth) / 2.0) ,startPoint.getY() - (double)pos *  (upperLBoardWidth - lboardSlotDept),startPoint.getZ(),//7
                            startPoint.getX() + ((lboardLHeight - lboardSlotWidth) / 2.0) ,startPoint.getY() - (double)pos *  (upperLBoardWidth - lboardSlotDept),startPoint.getZ(),//8
                            startPoint.getX() + ((lboardLHeight - lboardSlotWidth) / 2.0)  ,startPoint.getY() - (double)pos * upperLBoardWidth,startPoint.getZ(),//9
                            startPoint.getX() ,startPoint.getY() - (double)pos * upperLBoardWidth,startPoint.getZ()
                        };
                    }
                    return points;
                default:
                    points = new double[] { };
                    return points;
            }
            
        }

        //type-0-隐形平门边 1-平门边,2-隐形平盖片门边,3-平盖片门边
        public double[] DrawSingleEdge(Point startPoint, int view, int pos, int type)
        {
            double[] points;
            switch (view)
            {
                case 0:
                    if (type == 0)
                    {
                        points = new double[] {
                            startPoint.getX(),startPoint.getY(),startPoint.getZ(), //1
                            startPoint.getX() + (double)pos * hidePlainEdgeWidth,startPoint.getY(),startPoint.getZ(), //2
                            startPoint.getX() + (double)pos * hidePlainEdgeWidth,startPoint.getY() - (hidePlainEdgeHeight- hidePlainEdgeSlotWidth) / 2.0,startPoint.getZ(), //3
                            startPoint.getX()  + (double)pos * (hidePlainEdgeWidth - hidePlainEdgeSlotDept),startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0,startPoint.getZ(), //4
                            startPoint.getX()  + (double)pos * (hidePlainEdgeWidth - hidePlainEdgeSlotDept),startPoint.getY() - (hidePlainEdgeHeight - hidePlainEdgeSlotWidth) / 2.0 - hidePlainEdgeSlotWidth,startPoint.getZ(), //5
                            startPoint.getX()  + (double)pos * hidePlainEdgeWidth,startPoint.getY() - (hidePlainEdgeHeight- hidePlainEdgeSlotWidth) / 2.0 - hidePlainEdgeSlotWidth,startPoint.getZ(), //6

                            startPoint.getX()  + (double)pos * hidePlainEdgeWidth,startPoint.getY() - hidePlainEdgeHeight,startPoint.getZ(), //7
                            startPoint.getX(),startPoint.getY() - hidePlainEdgeHeight,startPoint.getZ(), //8
                        };
                    }
                    else if (type == 1)
                    {
                        points = new double[] {
                            startPoint.getX() ,startPoint.getY(),startPoint.getZ(),
                            startPoint.getX() + (double)pos * plainEdgeWidth,startPoint.getY(),startPoint.getZ(),
                            startPoint.getX() + (double)pos * plainEdgeWidth,startPoint.getY() - plainEdgeHeight,startPoint.getZ(),
                            startPoint.getX(), startPoint.getY() - plainEdgeHeight,startPoint.getZ(),
                        };
                    }
                    else if (type == 2)
                    {
                        points = new double[] {
                            startPoint.getX(),startPoint.getY(),startPoint.getZ(), //1
                            startPoint.getX() + (double)pos * hideCoverEdgeWidth,startPoint.getY(),startPoint.getZ(),//2

                            startPoint.getX() + (double)pos * hideCoverEdgeWidth,startPoint.getY() - (hideCoverEdgeHeight-hidePlainEdgeSlotWidth) / 2.0,startPoint.getZ(), //3
                            startPoint.getX() + (double)pos * (hideCoverEdgeWidth - hidePlainEdgeSlotDept),startPoint.getY() - (hideCoverEdgeHeight-hidePlainEdgeSlotWidth) / 2.0,startPoint.getZ(), //4

                            startPoint.getX() + (double)pos * (hideCoverEdgeWidth - hidePlainEdgeSlotDept),startPoint.getY() -  (hideCoverEdgeHeight- hidePlainEdgeSlotWidth) / 2.0 - hidePlainEdgeSlotWidth,startPoint.getZ(), //5

                            startPoint.getX() + (double)pos * hideCoverEdgeWidth,startPoint.getY() -  (hideCoverEdgeHeight-hidePlainEdgeSlotWidth) / 2.0 - hidePlainEdgeSlotWidth,startPoint.getZ(),//6

                            startPoint.getX() + (double)pos * hideCoverEdgeWidth,startPoint.getY() - hideCoverEdgeHeight,startPoint.getZ(),//7

                            startPoint.getX() + (double)pos * (HideCoverEdgerCoverWidth - (hideCoverEdgeCoverMaxWidth - hideCoverEdgeWidth)) ,startPoint.getY() - hideCoverEdgeHeight ,startPoint.getZ(),//8
                            startPoint.getX() + (double)pos * (HideCoverEdgerCoverWidth - (hideCoverEdgeCoverMaxWidth - hideCoverEdgeWidth)) ,startPoint.getY() - hideCoverEdgeCoverMaxHeight ,startPoint.getZ(),//9

                            startPoint.getX() - (double)pos * (hideCoverEdgeCoverMaxWidth - hideCoverEdgeWidth) ,startPoint.getY() - hideCoverEdgeCoverMaxHeight ,startPoint.getZ(),//10
                            startPoint.getX() - (double)pos * (hideCoverEdgeCoverMaxWidth - hideCoverEdgeWidth),startPoint.getY() - hideCoverEdgeHeight ,startPoint.getZ(),//11
                            startPoint.getX(),startPoint.getY() - hideCoverEdgeHeight ,startPoint.getZ()//12
                        };
                    }
                    else if (type == 3)
                    {
                        points = new double[] {
                            startPoint.getX(),startPoint.getY(),startPoint.getZ(), //1
                            startPoint.getX()  + (double)pos * plainCoverEdgeWidth,startPoint.getY(),startPoint.getZ(), //2
                            startPoint.getX()  + (double)pos * plainCoverEdgeWidth,startPoint.getY() - plainCoverEdgeHeight,startPoint.getZ(), //3

                            startPoint.getX()  + (double)pos * plainCoverEdgeCoverMaxWidth,startPoint.getY() - plainCoverEdgeHeight,startPoint.getZ(), //4
                            startPoint.getX() + (double)pos * plainCoverEdgeCoverMaxWidth,startPoint.getY() - plainCoverEdgeCoverMaxHeight,startPoint.getZ(), //5

                            startPoint.getX()  + (double)pos * (plainCoverEdgeCoverMaxWidth - PlainCoverEdgerCoverWidth) ,startPoint.getY() - plainCoverEdgeCoverMaxHeight ,startPoint.getZ(), //6
                            startPoint.getX()  + (double)pos * (plainCoverEdgeCoverMaxWidth - PlainCoverEdgerCoverWidth) ,startPoint.getY() - plainCoverEdgeHeight,startPoint.getZ(), //7
                            startPoint.getX() ,startPoint.getY() - plainCoverEdgeHeight,startPoint.getZ() //8
                        };
                    }
                    else
                    {
                        points = new double[] { };
                    }
                    return points;
                case 1:
                    if(type == 0)
                    {
                        points = new double[] {
                            startPoint.getX(),startPoint.getY(),startPoint.getZ(), //1
                            startPoint.getX() + (double)pos * hidePlainEdgeWidth,startPoint.getY(),startPoint.getZ(), //2
                            startPoint.getX() + (double)pos *hidePlainEdgeWidth,startPoint.getY() - hidePlainEdgeLength,startPoint.getZ(), //3
                            startPoint.getX(),startPoint.getY() - hidePlainEdgeLength,startPoint.getZ(), //4
                        };
                    }
                    else if(type == 1)
                    {
                        points = new double[] {
                            startPoint.getX(),startPoint.getY(),startPoint.getZ(), //1
                            startPoint.getX() + (double)pos * plainEdgeWidth,startPoint.getY(),startPoint.getZ(), //2
                            startPoint.getX() + (double)pos * plainEdgeWidth,startPoint.getY() - plainEdgeLength,startPoint.getZ(), //3
                            startPoint.getX(),startPoint.getY() - plainEdgeLength,startPoint.getZ(), //4
                        };
                    }
                    else if(type == 2)
                    {
                        points = new double[] {
                            startPoint.getX(),startPoint.getY(),startPoint.getZ(), //1
                            startPoint.getX() + (double)pos * hidePlainEdgeWidth,startPoint.getY(),startPoint.getZ(), //2
                            startPoint.getX() + (double)pos * hidePlainEdgeWidth,startPoint.getY() - hideCoverEdgeLength,startPoint.getZ(), //3
                            startPoint.getX(),startPoint.getY() - hideCoverEdgeLength,startPoint.getZ(), //4
                        };
                    }
                    else if(type == 3)
                    {
                        points = new double[] {
                            startPoint.getX(),startPoint.getY(),startPoint.getZ(), //1
                            startPoint.getX() + (double)pos * plainCoverEdgeWidth,startPoint.getY(),startPoint.getZ(), //2
                            startPoint.getX() + (double)pos * plainCoverEdgeWidth,startPoint.getY() - plainCoverEdgeLength,startPoint.getZ(), //3
                            startPoint.getX(),startPoint.getY() - plainCoverEdgeLength,startPoint.getZ(), //4
                        };
                    }
                    else
                    {
                        points = new double[] { };
                    }
                    return points;
                case 2:
                    points = new double[] { };
                    return points;
                default:
                    points = new double[] { };
                    return points;
            }
        }

        public double[] DrawSingleBoard(Point startPoint, int view, int pos,int num = 0)
        {
            double[] points;
            switch(view)
            {
                case 0:
                    points = new double[] {};
                    return points;
                case 1:
                    points = new double[] {
                        startPoint.getX(),startPoint.getY(),startPoint.getZ(),
                        startPoint.getX() + (num == 0 ? windowWidth : num == 1 ? windowWidth1:windowWidth2),startPoint.getY(),startPoint.getZ(),
                        startPoint.getX() + (num == 0 ? windowWidth : num == 1 ? windowWidth1:windowWidth2),startPoint.getY() - boardWidth,startPoint.getZ(),
                        startPoint.getX(),startPoint.getY() - boardWidth,startPoint.getZ(),
                    };
                    return points;
                case 2:
                    points = new double[] {
                        startPoint.getX(),startPoint.getY(),startPoint.getZ(),
                        startPoint.getX() + (double)pos * boardHeight,startPoint.getY(),startPoint.getZ(),
                        startPoint.getX() + (double)pos * boardHeight,startPoint.getY() - (double)pos * (boardWidth - boardSlotWidth) ,startPoint.getZ(),
                        startPoint.getX() + (double)pos * (boardHeight - boardSlotDept),startPoint.getY() - (double)pos * (boardWidth - boardSlotWidth) ,startPoint.getZ(),
                        startPoint.getX() + (double)pos * (boardHeight - boardSlotDept),startPoint.getY() - (double)pos * boardWidth ,startPoint.getZ(),
                        startPoint.getX(), startPoint.getY() - (double)pos * boardWidth ,startPoint.getZ()
                    };
                    return points;
                default:
                    points = new double[] { };
                    return points;
            }
        }

        public double[] DrawSingleLeaf(Point startPoint, int view, int pos, int num = 0)
        {
            int singleBladeNum = (bladeNum / windowNum);
            double singleBladeWidth = (hidePlainEdgeLength - (upperBoardWidth + lowerBoardWidth)) / singleBladeNum;

            double[] points;
            switch (view)
            {
                case 0:
                    points = new double[] { };
                    return points;
                case 1:
                    points = new double[] {
                        startPoint.getX(),startPoint.getY(),startPoint.getZ(),
                        startPoint.getX() + (num == 0 ? windowWidth : num == 1 ? windowWidth1:num == 2 ? windowWidth2 : 0),startPoint.getY(),startPoint.getZ(),
                        startPoint.getX() + (num == 0 ? windowWidth : num == 1 ? windowWidth1:num == 2 ? windowWidth2 : 0),startPoint.getY() - singleBladeWidth,startPoint.getZ(),
                        startPoint.getX(),startPoint.getY() - singleBladeWidth,startPoint.getZ(),
                    };
                    return points;
                case 2:
                    points = new double[] {

                    };
                    return points;
                default:
                    points = new double[] { };
                    return points;
            }
        }

        public double[] DrawSingleHinge(Point startPoint, int view, int pos)
        {
            double[] points;
            switch (view)
            {
                case 0:
                    points = new double[] { };
                    return points;
                case 1:
                    points = new double[] {
                            startPoint.getX() ,startPoint.getY(),startPoint.getZ(),
                            startPoint.getX() + (double)pos * hingeWidth,startPoint.getY(),startPoint.getZ(),
                            startPoint.getX() + (double)pos * hingeWidth,startPoint.getY() - hingeHeight,startPoint.getZ(),
                            startPoint.getX(), startPoint.getY() - hingeHeight,startPoint.getZ(),
                    };

                    return points;
                case 2:
                    points = new double[] { };
                    return points;
                default:
                    points = new double[] { };
                    return points;
            }
        }

        public void DrawWindowPart(Point startPoint, int view,int windowNo,double singleBladeWidth)
        {
            double[] partWindowUp, partWindowLow, partWindowUp1, partWindowLow1, partTextPos,textPos;
            double windowUpperArea,windowLowerArea;
            double partXOffset = 30;
            if (view == 1)
            {
                switch(windowNo)
                {
                    case 1:
                        windowUpperArea = window1UpperArea;
                        windowLowerArea = window1LowerArea;
                        break;
                    case 2:
                        windowUpperArea = window2UpperArea;
                        windowLowerArea = window2LowerArea;
                        break;
                    case 3:
                        windowUpperArea = window3UpperArea;
                        windowLowerArea = window3LowerArea;
                        break;
                    default:
                        windowUpperArea = 0;
                        windowLowerArea = 0;
                        break;
                }
                partWindowUp = new double[] { startPoint.getX() + partXOffset, startPoint.getY() - singleBladeWidth, startPoint.getZ() };
                partWindowLow = new double[] { startPoint.getX() + partXOffset, startPoint.getY() - windowUpperArea * singleBladeWidth, startPoint.getZ() };
                modelSpace.AddLine(partWindowUp, partWindowLow);
                partTextPos = new double[] { startPoint.getX() + (windowWidth / 2), startPoint.getY() - (windowUpperArea / 2) * singleBladeWidth, startPoint.getZ() };
                modelSpace.AddText(windowUpperArea.ToString(), partTextPos, singleBladeWidth);
                previewImg.AddLine(partWindowUp, partWindowLow);

                textPos = new double[] { partWindowUp[0] - 10 , (partWindowUp[0] + partWindowLow[0]) / 2, 0 };
                AcadDimRotated aligned1 = modelSpace.AddDimRotated(new double[] { partWindowUp[0], partWindowUp[1], partWindowUp[2] }, new double[] { partWindowLow[0], partWindowLow[1], partWindowLow[2] }, textPos,Math.PI / 2);
                aligned1.TextHeight = 10;
                aligned1.Update();
                previewImg.AddText(windowUpperArea.ToString(), partTextPos);

                partWindowUp1 = new double[] { startPoint.getX() + partXOffset, startPoint.getY() - (windowUpperArea + 1) * singleBladeWidth, startPoint.getZ() };
                partWindowLow1 = new double[] { startPoint.getX() + partXOffset, startPoint.getY() - (windowUpperArea + windowLowerArea) * singleBladeWidth, startPoint.getZ() };
                modelSpace.AddLine(partWindowUp1, partWindowLow1);
                partTextPos = new double[] { startPoint.getX() + (windowWidth / 2), startPoint.getY() - (windowUpperArea + (windowLowerArea / 2)) * singleBladeWidth, startPoint.getZ() };
                modelSpace.AddText(windowLowerArea.ToString(), partTextPos, singleBladeWidth);
                previewImg.AddLine(partWindowUp1, partWindowLow1);

                textPos = new double[] { partWindowUp1[0] - 10, (partWindowUp1[0] + partWindowLow1[0]) / 2, 0 };
                AcadDimRotated aligned2 = modelSpace.AddDimRotated(new double[] { partWindowUp1[0], partWindowUp1[1], partWindowUp1[2] }, new double[] { partWindowLow1[0], partWindowLow1[1], partWindowLow1[2] }, textPos, Math.PI / 2);
                aligned2.TextHeight = 10;
                aligned2.Update();
                previewImg.AddText(windowLowerArea.ToString(), partTextPos);
            }
        }
    }
}
